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 Create/Update Error

default discord avatar
genkwang2 years ago
1

I am trying to create/update using local api but getting TypeError: Cannot read properties of undefined (reading 'config').



Code:


const post = await payload.create({


collection: 'Hhh', // required


data: {


// required


title: 'Hhh',


},


});



Found the solution! I had to include the user info


const createResult = await payload.create({


collection: modelSlug, // required


data: {


// required


title: modelSlug,


...doc,


},


user: {


id: req.user.id,


collection: req.user.collection,


},


});

    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.