Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

fetch api only return ids of relationship field.

default discord avatar
_itsjustchris2 years ago
5

When GET request a collection endpoint (browser/postman) I get a full depth view of my relationship array, but when using the fetch api in my app I'm only receiving the IDs in the array. How can I get the full object instead of just the id?

  • default discord avatar
    tinouti2 years ago
    depth

    might be what you're looking for:

    https://payloadcms.com/docs/getting-started/concepts#depth
  • default discord avatar
    skry.2 years ago

    I had the same problem and I fixed it by adding a depth parameter in the url that I'm fetching (100 is probably to much)

  • default discord avatar
    _itsjustchris2 years ago

    I actually goofed up, I was working on the collection in dev, and my app was fetching from production. Thanks any way.

  • default discord avatar
    dengusdanny2 years ago

    You may not realize at the time of posting, but this just helped me solve my issue after looking for a long time!

  • default discord avatar
    _itsjustchris2 years ago

    Glad to be of service 😂

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.