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

多个请求,有且返回401后,如何优雅地阻止后续请求? #1838

Closed
ybning opened this issue Jul 31, 2018 · 5 comments
Closed
Labels

Comments

@ybning
Copy link

ybning commented Jul 31, 2018

有这样一个场景:
订单新增页,需要请求:客户列表接口 和 商品列表接口,
然而token过期了,访问这个页面时,2个接口同时返回401,
如何优雅地处理:第1个接口返回401后,后续的接口不再请求。

@ybning
Copy link
Author

ybning commented Jul 31, 2018

@sorrycc 大神帮帮忙

@memoryza
Copy link

@ybning 你是想要 接口1 接口2 串行请求是吗?那你可以在第一个请求const ret = yield call(xxxx, params);
以后再去yield put({type: method});这样就串行了啊

@keiseiTi
Copy link

猜测是并行。用const [data1,data2] = yield all[ call() , call() ] . if(data1.error || data2.error) { }

@fangkyi03
Copy link

这个很好解决
https://github.com/fangkyi03/dvajs
用我这个 如果数据发生异常的时候
直接发起一个取消的dispatch就可以取消之后网络请求的队列执行

@stale
Copy link

stale bot commented Mar 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 14, 2019
@stale stale bot closed this as completed Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants