4 ms·
I still write XMLHttpRequest and see no reason to switch. I depend on things like progress notifications and cancelations which fetch has iffy support for. htt
by Jasper_ 5y ago
I still write XMLHttpRequest and see no reason to switch. I depend on things like progress notifications and cancelations which fetch has iffy support for.
https://github.com/magcius/noclip.website/blob/master/src/DataFetcher.ts#L96 https://github.com/magcius/noclip.website/blob/master/src/Da...
- 6510 5y agoSame here. Look how clean it is! with(console){ with(new XMLHttpRequest()){ onload=()=>log(responseText); onerror=error; open("GET", "https://.."); send(); } } I'm only half joking.
- cyco130 5y agoMy... eyes... For people less familiar with the subject: console.log(await fetch("https:/...").then(r => r.text())) I agree progress reporting needs improvement though.
- easrng 5y agoProgress is possible with fetch, you just need to read from the stream yourself. And since you're working with the stream, you can also do things like parse newline-delimited JSON as it downloads instead of all at once at the end. https://fetch-progress-demo.glitch.me/ https://fetch-progress-demo.glitch.me/