Marko Marko - 25 days ago 10
Javascript Question

Javascript promise - replace arrow functions

Since the support for arrow functions in JS is still quite low, I'd like to replace them from the following code snippet:

Promise.all([f1(), f2()])
.then(values => { f3(values); })
.catch(values => { f4(values); });


Any idea how can this be achieved?

Answer

Should be straight forward, just type "function" instead

Promise.all([f1(), f2()]).then(function(values) { 
    f3(values); 
}).catch(function(values) { 
    f4(values); 
});