I am desperatly trying to get “createdBy” and “updatedBy” in my returned data … I tried querying with the parameter " populate=* " , I tried finding a solution in the documentation, I setup
but none of these seem to make it work for me. When I do a simple GET, i get the collection data, without the “createdBy” and “updatedBy” info… How can I get these ?
Ah, sorry I read your original post wrong. I thought it was createdAt and updatedAt that you were looking for, when you are actually looking for createdBy and updatedBy. I believe there is currently a long running bug with bringing back a user relationship in the api. Don’t remember the specifics (I’ll try to link the ticket when I find it) but I believe there is a sanitize method being called on the api that strips out any of the user data before it sends the response back to you. I think they hadn’t best decided on how to handle these situations when the user object could contain sensitive data. I think the current best way to fix this is to override your api endpoint and modify it to include your user data.
Ok. It explains a lot why it’s not working. I hope they will be able to fix that any soon…
In the meanwhile, could you help me with overwritting the api endpoint ? I’m really new to Strapi (since yesterday to be accurate), I’ve looked a bit in the documentation but it was not super clear to me …
So if you go to the directory:
src/api/YOUR_ENDPOINT_NAME/controllers/YOUR_ENDPOINT_NAME.js. Open up that file and you can override any of the methods on the controller. Controllers have a number of methods that are automatically created when you create an api. These are: find(), findOne(), create(), update(), delete().
For an example, I have an api called article. When I created that endpoint, it automatically created the controller for me in: src/api/article/controllers/article.js