Hi! I’m trying to populate a relation in a repeatable component but I’m not having any success. I feel like I’m just missing something basic. Any help is appreciated.
I’ve attached a screenshot of how I set up the relation. I’m using a custom controller to fetch the recipes by slug:
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::recipe.recipe', ({strapi}) => ({
async findOne(ctx) {
const { slug } = ctx.params;
const entity = await strapi.db.query('api::recipe.recipe').findOne({
where: { slug },
populate: {
steps: true,
ingredients: {
populate: {
ingredient: true,
}
}
},
});
const sanitizedEntity = await this.sanitizeOutput(entity);
return this.transformResponse(sanitizedEntity);
}
}));
Here I expect the steps to be populated as well as the ingredient attributes within the repeatable component including the relation to the Ingredient. But this is the response I’m getting:
{
"data": {
"id": 1,
"attributes": {
"name": "Recipe",
"slug": "recipe",
"createdAt": "2024-05-31T20:17:18.295Z",
"updatedAt": "2024-06-21T20:54:00.907Z",
"publishedAt": "2024-06-10T19:51:01.847Z",
"servings": 4,
"steps": [
{
"id": 1,
"instructions": "Step 1"
},
{
"id": 2,
"instructions": "Step 2"
},
{
"id": 3,
"instructions": "Step 3"
}
],
"ingredients": [
{
"id": 1,
"amount": 100,
"additional_information": "Test"
}
]
}
},
"meta": {
}
}```
<i>This topic has been created from a Discord post (1253815459455828032) to give it more visibility.
It will be on Read-Only mode here.
<a href="https://discord.com/channels/811989166782021633/1253815459455828032/1253815459455828032">Join the conversation on Discord</a></i>