I'm having an error when I try to use a simple afterFind trigger. I'm using Parse Server v4.2.0 via back4app
Parse.Cloud.afterFind('Device', async (req) => {
console.log(req);
});
but the app crashes and start to prompt the error message
afterFind expect results to be returned in the promise
I noticed two things:
What I'm missing?
Because you are using async
, it is expecting the promise to resolve to a query result. You have two options:
await
in your trigger, you can just remove the async
from your function:Parse.Cloud.afterFind('Device', (req) => {
console.log(req);
});
Parse.Cloud.afterFind('Device', async (req) => {
console.log(req);
return req.objects;
});