Resolve promise

14 views
Skip to first unread message

Uday Kumar

unread,
May 29, 2018, 1:44:48 PM5/29/18
to loopb...@googlegroups.com
How to resolve promise from remote method  in below the code ? 

Model.afterRemote('create', function(context,unused,next){ 
     while (startDay <= endDay) { // day1 to day365
 // there are some async operations(loops) which takes some time to     execute      
}
next(); // it gets execute before the loop gets finish  
});

Using loopback v3
and mongodb v3.

Thanks

Mark Johnson

unread,
May 29, 2018, 11:22:33 PM5/29/18
to LoopbackJS
While callback rather than promised based, the async library works well for things like this.  Look at async.each or async.eachSeries for starters
Reply all
Reply to author
Forward
0 new messages