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.

Local API find query not working.

default discord avatar
thebiltheory2 years 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?

  • default discord avatar
    jessrynkar2 years ago

    Hi

    @696064454189645854

    - 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
    thebiltheory2 years ago

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

  • default discord avatar
    jessrynkar2 years ago

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

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.