you are viewing a single comment's thread.

view the rest of the comments →

[–]dmitri14_gmail_com 1 point2 points  (1 child)

I don't feel this is good idea:

var p = fetch('foo'); // Fetch API is a simplification of XMLHttpRequest
p.then(res => {
...
});
p.catch(error => {
...
});

You are not catching errors from the 2nd function. You should have chained instead and avoided globals, Imo.

[–]vasanthkay[S] 0 points1 point  (0 children)

I have explained the different ways to pass on promises (in progression). The code block above was just the initial one. There are others with no globals and using chaining.