System Information
- Strapi Version: v4.3.0
- Operating System: MacOs
- Database: Sqlite
- Node Version: 16.14.2
- NPM Version: 8.5
- Yarn Version: 1.22.19
I can the category when I set one to many but when I change it to many to many the category isn’t populated.
{
"kind": "collectionType",
"collectionName": "categories",
"info": {
"singularName": "category",
"pluralName": "categories",
"displayName": "Category",
"name": "category"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"name": {
"type": "string",
"required": true
},
"slug": {
"type": "uid",
"targetField": "name",
"required": true
},
"articles": {
"type": "relation",
"relation": "manyToMany",
"target": "api::article.article",
"inversedBy": "categories"
}
}
}
{
"kind": "collectionType",
"collectionName": "articles",
"info": {
"singularName": "article",
"pluralName": "articles",
"displayName": "Article",
"name": "article",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string",
"required": true
},
"description": {
"type": "text",
"required": true
},
"content": {
"type": "richtext",
"required": true
},
"slug": {
"type": "uid",
"targetField": "title",
"required": true
},
"categories": {
"type": "relation",
"relation": "manyToMany",
"target": "api::category.category",
"inversedBy": "articles"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
]
},
"author": {
"type": "relation",
"relation": "manyToOne",
"target": "api::writer.writer",
"inversedBy": "articles"
}
}
}
On the frontend :
fetchAPI("/articles", { populate: ["image", "category"] }),
I’m learning strapi it comes from this blog article: