Got it to work by getting on the right track with the suggestions of @russian-dima . The solution was a combination of that as well as using toUpdate:
export function post_codeWorks(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
// get the request body
return request.body.json()
.then((body) => {
return updateProfile(body["_id"], body["qrCode"]);
})
.then((results) => {
options.body = {
"inserted": results
};
return created(options);
})
// something went wrong
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
});
}
async function updateProfile(profileId, qrCode) {
wixData.get("memberRegistration", profileId)
.then((toUpdate) => {
toUpdate.qrCode = qrCode;
wixData.update("memberRegistration", toUpdate)
.then((result) => {
// updated object details
console.log(result);
})
.catch((err) => {
let errorMsg = err;
});
})
}