PUT function to update database from external db

Trying to code PUT http function to update wix database from external database on the basis of the “_id” of the row.

Code is as below, but keep getting 500 error. Any suggestions?

export function put_updaterecords (request) {
return request.body.json()
.then(body => {
let recordUpdate = {
"_id": body.ID,
"title": body.Title, 
"firstName": body.FirstName,
"lastName": body.LastName,
"color": body.Color,
"number": body.Number
};
return wixData.update("SampleCollection", recordUpdate)
.then(result => ok({body: JSON.stringify(result)}))
.catch(err => response({status: 500, body: err}));
})
}

Hi.

I can’t see the wix-fetch API in your code. If you wish to access data from external services, you need to use the wix-fetch API. To learn more, check out this tutorial:
Corvid: Working with External Database Collections
Corvid: Working with External Database Collections

Good luck!

I’ve already fetched the data through a GET function. No problems there. Now I want to the update the data through PUT function which is not working as above. Wanted suggestions on that. (The POST function similarly created works fine, so was wondering of any inputs here as to why it wont work.)