Parse.Cloud.define("somefunc", async function (request) {
if ((request.params.somekey != process.env.SOME_KEY) || (request.params.someid != process.env.SOME_ID)) {
throw "error";
} else {
const allowedFields = ["client", "note"];
if (allowedFields.includes(request.params.editfield)) {
const query = new Parse.Query("some");
query.equalTo("id", request.params.id);
const results = await query.find({useMasterKey: true});
if (results.length === 0) {
throw "Not found";
} else {
let target = results[0];
target.set(request.params.editfield, request.params.newfieldval)
target.save(null, { useMasterKey: true })
.then((target) => {
return 'Edit successful: ' + target.id;
}, (error) => {
return 'Edit failed: ' + error.message;
});
}
} else {
throw "error, field not found";
}
}
});
Errors are returning just fine, but any successful operation just returns empty brackets, like this:
Can anyone point @ what Iām doing wrong? Would appreciate this!