Strapi populate

System Information
  • Strapi Version: 4.0
  • Operating System: macOS
  • Database: mySQL
  • Node Version: v14.19.1
  • NPM Version: v6.14.16
  • Yarn Version:

I’m trying to populate relation fields when find one by slug but it’s don’t return any data from relation fields as i want

async findOne(ctx) {
        const { slug } = ctx.params;
        const response = transformSuccessResponse(await strapi.query('api::faq.faq').findOne({
            where: { slug: slug }
        }, {
            populate: '*'
        }));
        if (response) {
            let diseasesTmp = [...response.data?.diseases?.data || []];
            response.data.diseases = diseasesTmp.map(ele => transformObjectToDefaultObject(ele));
        }
        return response ? parseToCamelCase(response) : transformErrorResponse(HttpStatus.NOT_FOUND);
    },

Someone can explain what’s wrong with my code.
Thanks.

1 Like

The Wildcard * doesn’t work for deeper nesting, so you need to populate the deeper Fields aswell (Like for Relations, Components and Dynamic Zones AFAIK)