Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can you do with XMLHttpRequest and cannot with Fetch API?

I know that as for 2020 the Fetch API can be considered a modern replacement for pretty much everything that was done with XMLHttpRequest. But I wonder if there are still things that can only be done with XMLHttpRequest at this point. Can XMLHttpRequest be completely dropped?

like image 771
Sorin GFS Avatar asked Sep 21 '25 03:09

Sorin GFS


1 Answers

I can imagine couple reasons, why you can use XMLHttpRequest:

First, you don't want to use polyfills, but need to support old browsers: https://caniuse.com/#search=fetch

Second you need something specific from XMLHttpRequest, that fetch can’t do, like upload https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/upload to track upload progress.

In other cases, use fetch.

like image 197
Kirill Avatar answered Sep 22 '25 18:09

Kirill