payload__WEBPACK_IMPORTED_MODULE_2__.default.find is not a function

default discord avatar
fpnv_71336last year
2

Hello Payload community!

:blobgoodmorning:



I am trying to use the payload local api inside of a react function component.


My component is inserted BeforeDashboard.


It seems the payload.init({...}) is not fully done whern the component gets called, and so payload is not properly initialized, resulting in this error :



Uncaught (in promise) TypeError: payload

WEBPACK_IMPORTED_MODULE_2

.default.find is not a function



Is there maybe another way to do what I'm trying to do?



Thanks!

  • You cannot use the local API inside of a react component. The local API is server side only, so unless you are using something like server components, then you will need to use REST or GraphQL to interact with your data 👍

  • default discord avatar
    fpnv_71336last year

    That does indeed explain everything!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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