Are you able to use react hooks?
I don't think you can within an access control function right?
As the access control functions are run on the server and you can't use react hooks inside of server components from my understanding.
Yeah, you can't because access controls are not Components.
Ah
But you can make a REST call
try {
const req = await fetch('{cms-url}/api/payload-preferences/{key}', {
method: "GET",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
})
const data = await req.json()
} catch (err) {
console.log(err)
}Yeah, I was thinking I could use the local api but I wasn't sure of the collection name.
Seems promising
I'll give it a try and see 🙂
Sorted it, should be:
const preferences = await payload.find({
collection: 'payload-preferences',
req: args.req,
where: {
key: {
equals: 'the-key',
},
},
})Thanks for the help
@486710146651652106o/
Star
Discord
online
Get dedicated engineering support directly from the Payload team.