In my collections I'm having a field called "author", having a relationship to my users table and per default set to user.id
But when querying the field using the rest api I'm getting the complete data from the users collections including all fields and also sensitive Data such as the api key.
The users name would be completely sufficient.
Can I change this anywhere? Some best practices?
checkout afterRead hook here
https://payloadcms.com/docs/hooks/collections#afterreadGood point 👍
I'll give it a try 😄
thx, worked as expected
how did you do could you share some dummy code
I'll share it as I finished it.
Had some correlation with other data/fields
Here's an example. If you don't want the field data to show at all in the response. set it to
undefined
like
doc.apiKey = undefined
.
https://github.com/payloadcms/payload/discussions/4400#discussioncomment-8547663i wanted to hide data from the res rather than the actual db
That is what this does.
Yes solved thanks
Star
Discord
online
Get dedicated engineering support directly from the Payload team.