Local API Create/Update Error

default discord avatar
genkwanglast year
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 help straight from the Payload team with an Enterprise License.