I’ve got this sort of content setup:
I’m trying to query this with the REST api, ideally I would actually just want to populate everything recursively, but since that doesn’t seem to be an option I’m trying to use populate to get all my fields.
My issue is, with both of those components I just can’t seem to populate the ‘Location’ fields, which is a 1:n relation to a Locations collection I have, here is how I’ve tried:
const query = qs.stringify({
populate: {
Tickets: {
populate: "Prices"
},
LocationInfobox: {
populate: {
Items: {
populate: "Location"
}
}
},
AccessibleLocations: {
populate: "Location",
}
},
}, {
encodeValuesOnly: true,
});
export const infoDataQuery = selector({
key: 'infoData',
get: async ({get}) => {
const response = await api.get('info-page?' + query);
console.log(response)
return response.data.data.attributes;
},
});
System Information
- Strapi Version: 4.0.0
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
It just doesn’t return anything for the field, I’ve tried the plural form ‘Locations’ as well, and also lowercase ‘locations’, since that’s what the internal content manager API seems to return, but no success.
It seems like this is only the case for this 1:n relation from a component, because ‘Items’ seems to to populate just fine.
Any insight on what I’m doing wrong would be greatly appreciated, it’s really frustrating seeing the content-manager api return the values I need, for the backend but having no idea how to query them myself…