-
Notifications
You must be signed in to change notification settings - Fork 14
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
错误重试中间件貌似次数限制未起作用?? #31
Comments
能弄个仓库,复现一下吗? |
这有个简单的示例,无限循环请求。https://codesandbox.io/s/quiet-violet-duepv?file=/src/App.js |
感谢,找到原因所在了,等我修复一下,发一个版本。 |
@itmanyong 已经修复了,要重新装一下安装包,或者你直接在你代码里,新建个文件,把代码https://github.com/xdoer/PreQuest/blob/main/packages/error-retry/src/index.ts粘贴过去用 |
拦截器有注册到中间件吗? |
|
我这边测试结果是没问题的。 测试过程如下: <!---demo.ts---->
import { create } from '@prequest/miniprogram'
import Taro from '@tarojs/taro'
const prequestInstance = create(Taro.request, {
baseURL: 'http://localhost:8000'
})
export default prequestInstance 页面文件 import { View } from '@tarojs/components'
import preInstance from '@common/demo'
import { create } from '@prequest/miniprogram'
import Taro from '@tarojs/taro'
export default function () {
function common() {
preInstance.post('/token').then(res => {
console.log('查看响应1', res)
})
create(Taro.request).post('http://localhost:8000/token').then(res => {
console.log('查看响应2', res)
})
}
return (
<View>
<View onClick={common}>普通请求</View>
</View>
)
} |
我尝试了你的例子没有问题,加上responseType:json之后就不可以; 你试一下呢,我反复尝试了几次,确实是注销; responseType设置就可以一致,貌似上面的响应拦截也是由于这个导致 |
Taro 的 responseType 不支持 json,传了导致响应不了,用原始的 Taro.request 请求也一样。 |
感觉可以兼容一下 |
请求库层面兼容不了,因为本质上是通过 success 和 fail 回调函数,来判断请求成功与否,如果 Taro.request 没有响应,请求库层面就会认为一直处于请求的过程中。。这个只能给 Taro 提 RP 了 |
情况:创建prerequest实例,只挂载错误重试中间件,中间件具体配置如下,但是请求之后貌似一直再重试。
The text was updated successfully, but these errors were encountered: