fetch API
http-request research
- XHR
- https://github.com/axios/axios Promise based HTTP client for the browser and node.js (
axios
)
- https://github.com/axios/axios Promise based HTTP client for the browser and node.js (
- Fetch
- for Browser
- https://github.com/JakeChampion/fetch A window.fetch JavaScript polyfill.(
whatwg-fetch
) use xhr to polyfill. - https://github.com/developit/unfetch 🐕 Bare minimum 500b fetch polyfill.(
unfetch
) - https://github.com/sindresorhus/ky 🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API (
ky
)
- https://github.com/JakeChampion/fetch A window.fetch JavaScript polyfill.(
- for Node
- https://www.npmjs.com/package/node-fetch (
node-fetch
)
- https://www.npmjs.com/package/node-fetch (
- for Browser
- cross-platform
- https://github.com/developit/unfetch/tree/main/packages/isomorphic-unfetch Switches between unfetch & node-fetch for client & server. (
isomorphic-unfetch
) - https://github.com/lquixada/cross-fetch Switches between https://github.com/bitinn/node-fetch/ & whatwg-fetch for client & server. (
cross-fetch
) - interceptors
- https://github.com/developit/unfetch/tree/main/packages/isomorphic-unfetch Switches between unfetch & node-fetch for client & server. (
fetch Browser Support
use polyfill whatwg-fetch
:
- https://github.com/JakeChampion/fetch#browser-support
- Chrome
- Firefox
- Safari 6.1+
- Internet Explorer 10+
npm trends for browser
Result: whatwg-fetch
got the most download counts for fetch
api
npm trends for nodejs
Result: node-fetch
got the same download counts with axios
npm trends for all
Consolution is to use cross-fetch
.