S G6,243 Points
I didn't understand why you need to use xhr.onerror, doesn't statusText provide all the errors?
this line : reject( Error(xhr.statusText) )
vs this line: xhr.onerror = () => reject ( Error('A network error occurred') )
KRIS NIKOLAISEN54,369 Points
He explains in the video @ 2:15:
Now if at some point there's a network connectivity issue, a status code wouldn't be provided. So let's also use the onerror event handler on the xhr object to reject the promise if the HttpRequest fails due to connectivity issues.