You're not wrong, and the extra step is a bit misunderstood, although important if you want to stream large binary files (I used it in this PWA demo to show a %βblink and you'll miss it).
I have a few unrelated thoughts:
await makes the flow much nicer than Chris' examples
I'm also surprised neither link uses onload, instead using the more confusing onreadystatechange (and this is actually a vote for XHRs).
the lack of support for responseType = 'json' in IE11 actually makes XHRs more confusing, since you just can't safely use that parameter and you have to add a JSON.parse call too
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You're not wrong, and the extra step is a bit misunderstood, although important if you want to stream large binary files (I used it in this PWA demo to show a %βblink and you'll miss it).
I have a few unrelated thoughts:
await
makes the flow much nicer than Chris' examplesonload
, instead using the more confusingonreadystatechange
(and this is actually a vote for XHRs).responseType = 'json'
in IE11 actually makes XHRs more confusing, since you just can't safely use that parameter and you have to add aJSON.parse
call too