Response from api

Good evening, I just found strapi and started using it tonight. I like how easy to use it is. I have one issue I will like to get fixed. Can the response from the api be modifeied to show in this format : http://localhost:1337/api/works should give the below response

{
            "id": 1,
             "name": "Kubona Website Redesign",
                "description": "Conversion of Kubona.ng from ASP.NET core MVC to Angular",
                "createdAt": "2022-01-30T18:06:02.891Z",
                "updatedAt": "2022-01-30T18:40:27.273Z",
                "publishedAt": "2022-01-30T18:40:27.270Z",
                "workImage": null
            }
```  instead of the current format. The current format makes api consumption a very hard task.



Someone should please guide me. Thanks

No response yet from anyone.

Good morning,
I just discovered strapi and I’m currently stuck at customizing my API responses.

Strapi’s response looks like this:
{“data”: [
{
“id”: 1,
“attributes”: {
“name”: “Kubona Website Redesign”,
“description”: “Conversion of http://Kubona.ng from http://ASP.NET core MVC to Angular”,
“createdAt”: “2022-01-30T18:06:02.891Z”,
“updatedAt”: “2022-01-30T18:40:27.273Z”,
“publishedAt”: “2022-01-30T18:40:27.270Z”,
“workImage”: null
}
},
{
“id”: 2,
“attributes”: {
“name”: “Kubona Admin Website”,
“description”: “Built form scrat the admin website to manage activities on ubona wesite.”,
“createdAt”: “2022-01-30T21:36:02.561Z”,
“updatedAt”: “2022-01-30T21:36:04.129Z”,
“publishedAt”: “2022-01-30T21:36:04.127Z”,
“workImage”: null
}
}
],
“meta”: {
“pagination”: {
“page”: 1,
“pageSize”: 25,
“pageCount”: 1,
“total”: 2
}
}
}

Is there a way to customize it to look like this:
{
“id”:1,
“name”:“This is a name”,
“description”:“The description is here”
},
{ … another object},

We just did a live stream, and I mentioned this plugin that does this. Transformer | Strapi Market

Sorry for super late response.

In terms of the current response structure, it is that way to support future features that are in the works.

Also, are you on our Discord channel? Great place to ask questions. Let me know if you have any other questions.

Thank you. I will check it out and give you a feedback

1 Like

Here is the video where I mention it. ✂️ Transformer Plugin - YouTube Let me know if you have questions about how to set it up. It should be pretty straight forward. But let me know.

I have set it up. and it worked. There is room for improvement to have just a response in a simpler JSON format without “data:[]”. Thanks for your help.

There is still a pending issue though - https://forum.strapi.io/t/fetch-data-belonging-to-only-an-authenticated-user/20656.

Hello!

We’ve discussed this several times after the release of v4 and decided we won’t switch (back) to another fornat anytime soon. The current one allows some features that are currently under development to be properly represented at the API level (such das versions, drafts, locales). Right now it might seem a bit convoluted (I personally agree with you), but it will play out it strengths in the near future.

The marketplace lists a plugin which allows you to transform the API responses: Transformer | Strapi Market, but please be aware, that this might break at some point or require more work, if we ship additional features.