System Information
- Strapi Version: 4.11.1
- Operating System:
- Database:
- Node Version: 18.16
- NPM Version:
- Yarn Version:
I created a custom controller and used the findOne API to retrieve an article from the resource. However, the response is not the same as the response from the ‘/articles/:id’ endpoint.
All of the default Strapi controllers return an Object with the ‘attributes’ field, but the controller I created does not have the ‘attributes’ field. How can I make them the same?
// strapi controller
{
"data": {
"id": 3,
"attributes": {
"title": "Title",
"content": "Content",
"description": null,
"publishTime": null,
"createdAt": "2023-07-11T03:26:09.261Z",
"updatedAt": "2023-07-11T03:26:31.010Z",
"subtitle": null,
"thumb": {
"data": null
},
"category": {
"data": {
"id": 1,
"attributes": {
"title": "",
"description": null,
"createdAt": "2023-07-09T14:16:44.621Z",
"updatedAt": "2023-07-09T14:16:44.621Z"
}
}
}
}
},
"meta": {}
}
// custom controller
{
"id": 3,
"title": "Title",
"content": "Content",
"description": null,
"publishTime": null,
"createdAt": "2023-07-11T03:26:09.261Z",
"updatedAt": "2023-07-11T03:26:31.010Z",
"subtitle": null,
"thumb": null,
"category": {
"id": 1,
"title": "",
"description": null,
"createdAt": "2023-07-09T14:16:44.621Z",
"updatedAt": "2023-07-09T14:16:44.621Z"
}
}