Cast to ObjectID Failed

default discord avatar
zinox9
3 months ago
5

Hi, am getting this error, I want to render the projects that are in the users field. Can't find what am doing wrong.

  • default discord avatar
    .bakry
    3 months ago

    it seems like you are passing a whole object instead of ID i believe

  • default discord avatar
    zinox9
    3 months ago

    Thats how it was built in this demo 🤔



    Anyone ?



    Gotta solve this urgently anyone there to help ?

    image.png
  • default discord avatar
    derosul
    3 months ago

    Hmm, that's weird. idk if the demo is still up to date in that case?


    As @.bakry mentioned, seems like its trying to cast the entire object to an ObjectID. can you try to just pass in an array of object Id's? 🤔



    so instead of



    in: user.projects


    Try something like



    in: user.projects.map((project) => project.id)
  • default discord avatar
    zinox9
    3 months ago

    Got it



    yep thats working

  • default discord avatar
    derosul
    3 months ago

    Nice!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.