This is what I’m getting. Only the id is not in a the attributes object. None of the examples I have seen do this.
"content": "This is a prompt"
"content": "This is a prompt 2"
"content": "This is a prompt 3"
Since Strapi v4 responses are different. Now all attributes are grouped inside ‘attributes’.
Except ID but yes, it’s the new v4 structure
Is there a way to revert to how Strapi 3 returned data? Is there a reason it changed?
And yes - would be nice if the examples here showed this change.
Feel free to tell me to RTFM if this was written about somewhere - but post the link
I also don’t understand. @strapi Team please explain why this decision was made.
It makes development way more complicated.
I agree with you. When we do abstraction on class models, it forcing us about some static fields. it is bad idea, please tell us why did you that?
-Notice: there is a plugin that name is transformer but it shouldnt be required.
It’s become quite difficult because the entire set of responses has changed. Not just that even the relations have data and attributes fields which make it quite complicated to deserialise the responses.
I thought v4 would be a change in the structure/working of Strapi but the change is huge in terms of outputs. It’s breaking lots of stuff for me.
It’s good that I still have the Strapi v3 instance installed on a separate server, else it’s pretty hard to update everything.
I didn’t see anything regarding why the team made that decision. Is it explain somewhere else ? It’s breaking a lot of stuff here too I registered precisely for that.
@BLu On Strapi V4 the get response do not return all the data by default, but you can populate all the data you want in your response, you can find it here:
You can use this plugin to get the API response you need
I had the same problem, and I ended up making a script that parses the GraphQL complex response into a simple one while keeping the right typescript types. The idea is to use it in the frontend.
Find it here: Flatten Strapi 4's response JSON · GitHub