Access Local API in Custom View

default discord avatar
Enrico
7 months ago
5

I am trying to access Payload Local Api in my custom view that is overwriting the "List" view of one collection, if I import payload and I try to access payload.find I get

payload__WEBPACK_IMPORTED_MODULE_1__.default.find is not a function
  • default discord avatar
    Jesse Sivonen
    7 months ago

    You cannot access Local API from front-end if I understood correctly. You must use either REST or GraphQL. In admin panel there might be some ready-made way to access the REST API. Maybe using React hooks?

  • default discord avatar
    Enrico
    7 months ago

    Now i understand, thank you

  • default discord avatar
    René
    4 months ago

    @Enrico How did you solve this?

  • default discord avatar
    Enrico
    4 months ago

    @René I used the standard REST api:

    https://payloadcms.com/docs/rest-api/overview
  • default discord avatar
    René
    4 months ago

    @Enrico Alright. Thanks.

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.