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

fetch #7

Open
teachat8 opened this issue Oct 31, 2018 · 0 comments
Open

fetch #7

teachat8 opened this issue Oct 31, 2018 · 0 comments

Comments

@teachat8
Copy link
Owner

teachat8 commented Oct 31, 2018

优势:
1.更加底层,提供的API丰富(request, response)
2.脱离了XHR,是ES规范里新的实现方式

不足:
1.fetch只对网络请求报错,对400,500都当做成功的请求,需要封装去处理
2.fetch默认不会带cookie,需要添加配置项
3.fetch不支持abort,不支持超时控制,使用setTimeout及Promise.reject的实现的超时控制并不能阻止请求过程继续在后台运行,造成了流量的浪费
4.fetch没有办法原生监测请求的进度,而XHR可以

[资料]:
传统 Ajax 已死,Fetch 永生
fetch 没有你想象的那么美

封装:
让fetch也可以timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant