Local API Create/Update Error

default discord avatar
genkwang
last month
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,


},


});

    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.