Local API find query not working.

default discord avatar
TheBilTheory
4 weeks ago
3

## Fetch the whole collections


  const payload = await getPayloadClient();

  // Works Perfectly ✅
  const projects = await payload.find({
    collection: "projects",
  });


## Fetch Single project



  const payload = await getPayloadClient();

  // Doesn't Work ❌
  const projects = await payload.find({
    collection: "projects",
    where: {
      slug: {
        equals: "adidas",
      },
    },
  });

  const project = projects.docs[0]; // undefined, should be { slug: 'adidas', ... }


## Terminal Errors


I'm taking the it's not working because of the attached errors?

  • discord user avatar
    jesschow
    Payload Team
    4 weeks ago

    Hi @TheBilTheory - your local API requests look correct, I just tested out the 'fetch single project' and it worked as expected.



    I also think it is these errors causing the trouble here... Have you installed your dependencies? What version of Payload are you on?

  • default discord avatar
    TheBilTheory
    4 weeks ago

    I switched to NPM instead of PNPM and it seems to have solved the problem.

  • discord user avatar
    jesschow
    Payload Team
    4 weeks ago

    Interesting... glad it's working for you now anyhow 😆

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.