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

关于请求错误重连的问题 #2

Closed
c1184405532 opened this issue May 8, 2020 · 3 comments
Closed

关于请求错误重连的问题 #2

c1184405532 opened this issue May 8, 2020 · 3 comments

Comments

@c1184405532
Copy link

c1184405532 commented May 8, 2020

老哥 请问 如果发送一个请求A 此时A请求报错了 进入了响应错误拦截器回调 在这个回调中如何去重新再次发起前一次请求,并且成功后能在A请求的.then(success=>{})中进行触发。
现在遇到的问题是 只要请求报错进入拦截器 就会触发 A请求.then(success=>{},error=>{})中的error回调
就算我返回的是promise依然会进入error 无法进行多次请求重试的效果
响应错误拦截器回调中的代码

const backoff = new Promise(function(resolve){
        setTimeout(()=>{
            resolve()
        },config.custom.retryDelay || 16)
    })
    return backoff.then(()=>{
        return instance.request(config)
       //此处instance.request(config).then(succes=>{})会触发数据回调 但是怎么把数据回调给到页面中的请求呢?
    })
@lei-mu
Copy link
Owner

lei-mu commented May 11, 2020

你说的是jwt 无痛刷新吗?等我有时间了整理个方案。还有的情况就是断网情况,在主要的页面里应该有重试按钮。如果是个别接口可以进行自己封装,在catch 里做自调用。

@c1184405532
Copy link
Author

你说的是jwt无痛刷新吗?等我有时间了整理个方案。还有的情况就是断网情况,在主要的页面里应该有重试按钮。如果是个别接口可以进行自己封装,在catch里做自调用。

嗯嗯 是这个意思 。好的 辛苦大佬了

lei-mu added a commit that referenced this issue Jun 21, 2020
@lei-mu lei-mu closed this as completed Jun 21, 2020
@c1184405532
Copy link
Author

辛苦老哥,我把React的app模板搭建完就回头把以前uniapp的无痛刷新加上

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

2 participants