Search code examples
jsonstrapi

Strapi simple API


I should make a simple API:

[
   {
     "social": "facebook",  
     "configuration: {
         "enabled": true,  
      }
   }
]

To do this, in content-type-builder I created this strapi interface Unfortunately the answer to the GET (using postman) is this:

{
    "data": [
        {
            "id": 1,
            "attributes": {
                "social": "facebook",
                "createdAt": "2024-01-23T15:39:52.979Z",
                "updatedAt": "2024-01-23T15:48:05.031Z",
                "publishedAt": "2024-01-23T15:48:05.028Z"
            }
        },
....
],
    "meta": {
        "pagination": {
            "page": 1,
            "pageSize": 25,
            "pageCount": 1,
            "total": 4
        }
    }
}

Could you tell me where I'm wrong? I don't understand why the enabled attribute is not displayed. Is important that the attribute enabled is inside configuration.


Solution

  • if you make a component that implies a relation so when fetching do it with populate

    /endpoint?populate=*

    can checkout this post of mine https://stackoverflow.com/a/77867922/8243241