After all rsvp promises are done in ember controller, how can I save all error status in controller and update DOM? I got undefined 'this', controller no longer accessible.
export default class someController extends Controller {
@tracked errorlist = [];
@action someAction {
RSVP.allSettled(prommises).then(function(retarray){
retarray.forEach((retstate) => {
if (retstate.state == 'rejected') {
this.errorlist.push(stateRet.reason);
//'this' undefined, how to update errlist?
}
});
})
}
}
There are a few things you could try, but this (less elegant) solution should give you the result you’re looking for:
❦
Personally, I’d move that
errorlist.push
into its own method on the controller, so you could call something like this: