Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axios vs fetch #35

Open
1 task done
suukii opened this issue Aug 19, 2020 · 0 comments
Open
1 task done

axios vs fetch #35

suukii opened this issue Aug 19, 2020 · 0 comments

Comments

@suukii
Copy link
Owner

suukii commented Aug 19, 2020

axios fetch
兼容性 兼容性好,甚至支持 IE11 兼容性没那么好,但是可以通过 whatwg-fetch 这样的 polyfill 库来弥补
超时设置 可以通过 timeout 属性设置超时时间 可以通过 AbortController API 加上定时器来实现
数据格式 会自动把数据转换成 JSON 格式(可以改写) 需要自行转换数据格式
拦截器 提供拦截器拦截 HTTP 请求 可以通过改写原生的 fetch 方法来实现拦截器的效果
进度条 通过 axios progress bar 模块能轻松实现 在响应数据 body 中提供 ReadableStream 实例,可以通过这个实例来实现进度条功能
并行请求 提供 axios.all()axios.spread() 可以借助 Promise.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant