Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Populate multiple levels not working as expected #26

Open
2 of 3 tasks
douwepausma opened this issue Jan 10, 2025 · 0 comments
Open
2 of 3 tasks

[bug]: Populate multiple levels not working as expected #26

douwepausma opened this issue Jan 10, 2025 · 0 comments
Labels
issue: bug Issue reporting a bug status: to be confirmed The issue needs to be reproduced or confirmed by a team member

Comments

@douwepausma
Copy link

Bug Description

At first I thought I need to use an array to populate much like the other Strapi API's, but when I hover the populate attribute (see the picture at expected behavior) I noticed I need to use an object. However it only works when ik go no further than 1 level.

This works

const results = await strapi.collection('pages').find({
        populate: {
            seo: true
        }
});

But this doesn't

const results = await strapi.collection('pages').find({
        populate: {
            seo: {
                metaImage: true
            }
        }
});

Steps to Reproduce

Try and fetch entries with a populate level deeper than 1.

const results = await strapi.collection('pages').find({
        populate: {
            seo: {
                metaImage: true
            }
        }
});

Expected Behavior

To populate multiple levels.

Version

1.0.0-beta.0

Operating System

MacOS

Runtime Environment

Node.js

Logs

⨯ HTTPBadRequestError: Request failed with status code 400 Bad Request: GET http://127.0.0.1:1337/api/pages?filters%5Bpathname%5D=%2Ftrainingen%2Fabout-me&populate%5Bseo%5D%5BmetaImage%5D=true
    at async getPageByPathname (./src/actions/strapi/page.ts:15:21)
    at async Page (./src/app/[...slug]/page.tsx:34:5)
digest: "2498158417"

TRYING THE REQUEST IN POSTMAN:
{
    "data": null,
    "error": {
        "status": 400,
        "name": "ValidationError",
        "message": "Invalid key metaImage at seo.metaImage",
        "details": {
            "key": "metaImage",
            "path": "seo.metaImage",
            "source": "query",
            "param": "populate"
        }
    }
}

Media

populate description

image

Confirmation Checklist

  • I have checked the existing issues
  • I agree to follow this project's Code of Conduct
  • I would like to work on this issue
@douwepausma douwepausma added issue: bug Issue reporting a bug status: to be confirmed The issue needs to be reproduced or confirmed by a team member labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug status: to be confirmed The issue needs to be reproduced or confirmed by a team member
Projects
None yet
Development

No branches or pull requests

1 participant