javascript - Strapi api doesn't return image field - Stack Overflow

I'm in a pretty strange situation.the url apihome-page?populate=* doesn't return my image

I'm in a pretty strange situation.

the url /api/home-page?populate=* doesn't return my image field but /api/home-page?populate=heroImage does

On the other side I have another single page very similar where populate=* and populate=heroImage are both working fine.

What can explain that problem?

Below the two schema.json

home-page :

{
  "kind": "singleType",
  "collectionName": "home_pages",
  "info": {
    "singularName": "home-page",
    "pluralName": "home-pages",
    "displayName": "Page d'accueil",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string"
    },
    "description": {
      "type": "text"
    },
    "seo": {
      "type": "component",
      "repeatable": false,
      "component": "shared.seo"
    },
    "heroImage": {
      "type": "media",
      "multiple": false,
      "required": false,
      "allowedTypes": ["images"]
    },
    "img": {
      "allowedTypes": ["images"],
      "type": "media",
      "multiple": false
    }
  }
}

the other page :

{
  "kind": "singleType",
  "collectionName": "ou_trouver_bonuxes",
  "info": {
    "singularName": "ou-trouver-bonux",
    "pluralName": "ou-trouver-bonuxes",
    "displayName": "Où trouver Bonux"
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string"
    },
    "description": {
      "type": "text"
    },
    "heroImage": {
      "allowedTypes": [
        "images"
      ],
      "type": "media",
      "multiple": false
    }
  }
}

I'm in a pretty strange situation.

the url /api/home-page?populate=* doesn't return my image field but /api/home-page?populate=heroImage does

On the other side I have another single page very similar where populate=* and populate=heroImage are both working fine.

What can explain that problem?

Below the two schema.json

home-page :

{
  "kind": "singleType",
  "collectionName": "home_pages",
  "info": {
    "singularName": "home-page",
    "pluralName": "home-pages",
    "displayName": "Page d'accueil",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string"
    },
    "description": {
      "type": "text"
    },
    "seo": {
      "type": "component",
      "repeatable": false,
      "component": "shared.seo"
    },
    "heroImage": {
      "type": "media",
      "multiple": false,
      "required": false,
      "allowedTypes": ["images"]
    },
    "img": {
      "allowedTypes": ["images"],
      "type": "media",
      "multiple": false
    }
  }
}

the other page :

{
  "kind": "singleType",
  "collectionName": "ou_trouver_bonuxes",
  "info": {
    "singularName": "ou-trouver-bonux",
    "pluralName": "ou-trouver-bonuxes",
    "displayName": "Où trouver Bonux"
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string"
    },
    "description": {
      "type": "text"
    },
    "heroImage": {
      "allowedTypes": [
        "images"
      ],
      "type": "media",
      "multiple": false
    }
  }
}
Share Improve this question asked Nov 18, 2024 at 12:41 Rom-888Rom-888 8862 gold badges14 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

With the populate=* parameter, it returns first-level relations, components and dynamic zones.

You can use Strapi deep populate plugin. Install the plugin

npm i strapi-plugin-populate-deep

and make the requests like

/api/articles?populate=deep

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745617624a4636330.html

相关推荐

  • javascript - Strapi api doesn't return image field - Stack Overflow

    I'm in a pretty strange situation.the url apihome-page?populate=* doesn't return my image

    7小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信