简体   繁体   中英

Parse trigger error, afterFind expect results to be returned in the promise

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:

  • The error is also in the Device class
  • The error is only in some function

What I'm missing?

Because you are using async , it is expecting the promise to resolve to a query result. You have two options:

  1. since you are not using await in your trigger, you can just remove the async from your function:
Parse.Cloud.afterFind('Device', (req) => {
   console.log(req);
});
  1. You can return the objects at the end:
Parse.Cloud.afterFind('Device', async (req) => {
   console.log(req);
   return req.objects;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM