Search code examples
htmlnode.jsreactjsstrapi

Strapi repeatable Component Not Sending Image Obj with Populate=*


This is a repeatable component of strapi:

SS 1

Api call:

Api call

     {
        "id": 1,
        "attributes": {
         ../other fields
            "imgs": [
                {
                    "id": 37,
                    "title": "KeyNote Lecture",
                    "subtitle": "Felicitation in Chennai, Molaris 2022"
                },
    ../Same Objects
            ],
        }
    }

See API call getting the only title, subtile, id only. but the image not getting.

Please, anyone, help.


Solution

  • this is because populate=* gives only first level of relations, and image inside component is a relation of second level:

    Option one (easiest) use yarn add strapi-plugin-populate-deep /api/course-director?populate=deep

    Option two use qs:

    const str = qs.stringify(
      {
        populate: { imgs: { populate: ["image"] } }
      },
      { encodeValuesOnly: true }
    );
    
    populate[imgs][populate][0]=image