I have a put JSON generated from Zapier that will be updating a database in my website via the id. I keep getting a NOT FOUND error even though I know that the id does exist in my live database. Any help is appreciated.
import { ok, serverError, notFound } from 'wix-http-functions';
import wixData from 'wix-data';
import wixUser from 'wix-users';
export function put_test(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
// get the request body
return request.body.json()
.then(body => {
let toUpdate = {
"_id": body._id,
"fullName": body.fullName,
"assetAllocation": body.assetAllocation,
"esg": body.esg,
"avgexpenseratio": body.avgexpenseratio,
"currentBalance": body.currentBalance,
"a1MonthlyDeposit": body.a1MonthlyDeposit
};
// update the item in a collection
return wixData.update("sampleData", toUpdate);
})
.then((results) => {
options.body = {
"inserted": results
};
return ok(options);
})
// something went wrong
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
});
}