Model attributes

Hello guys,

I have a question in reference to model attributes that are returned in the response from a GET request. I have a simple Product model that has a user (the person created the product) and when I fetch a specific product I get the following response:

image

My question is, how can I hide the password attribute of the user in the response because I don’t think it’s a good idea to return the hash like that? And also is it even possible to do it, if yes, can it be done for multiple attributes?

Thank you in advance guys!

Regards :slight_smile:

You should use sanitizeEntity function, which removes all private fields from the model and its relations.

Take a look in documentation, at the Utils section:
https://strapi.io/documentation/v3.x/concepts/controllers.html#core-controllers

1 Like

Thank you very much @sunnyson! I think this topic can be closed now :slight_smile:

1 Like