Has anyone ever done this successfully?
I'm having the following issue when I try to do it:
setPreference('key', true);
const preference = await getPreference('key');
console.log(preference, typeof preference); // true, boolean
setPreference('key', false);
const preference = await getPreference('key');
console.log(preference, typeof preference); // {value: false}, object
Payload returns an object with a
value
property set to false instead of returning
false
. 🤔
I worked around it doing this:
const preference = await getPreference('key');
setPreference(preference && typeof preference === "boolean");
But I'm wondering if this behavior is a bug or if it's working as intended. 🤔
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.