Comments (13)
能弄个仓库,复现一下吗?
from prequest.
这有个简单的示例,无限循环请求。https://codesandbox.io/s/quiet-violet-duepv?file=/src/App.js
from prequest.
感谢,找到原因所在了,等我修复一下,发一个版本。
from prequest.
@itmanyong 已经修复了,要重新装一下安装包,或者你直接在你代码里,新建个文件,把代码https://github.com/xdoer/PreQuest/blob/main/packages/error-retry/src/index.ts粘贴过去用
from prequest.
版本:"@prequest/interceptor": "^1.0.3"、"@prequest/miniprogram": "^1.0.3"
情况:按照文档例子,响应拦截器貌似拦截不了,成功的请求拦截其中完全拦截不了,仿佛没有进入。如下图所示,请求成功了,但没有进入响应拦截。甚至在请求完成后我也无法拿到数据。
from prequest.
拦截器有注册到中间件吗?
from prequest.
令我无法理解的是:同样是创建的实例同一个接口,一个可以拿到数据而封装导出的缺无法拿到数据!!!
1.封装实例,直接导出,不做任何中间件处理
from prequest.
拦截器有注册到中间件吗?
拦截器已注册到中间件,控制台也打印了请求拦截的配置。就是响应拦截未有响应。
from prequest.
我这边测试结果是没问题的。
测试过程如下:
<!---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>
)
}
from prequest.
我这边测试结果是没问题的。
测试过程如下:
<!---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设置就可以一致,貌似上面的响应拦截也是由于这个导致
from prequest.
Taro 的 responseType 不支持 json,传了导致响应不了,用原始的 Taro.request 请求也一样。
from prequest.
Taro 的 responseType 不支持 json,传了导致响应不了,用原始的 Taro.request 请求也一样。
感觉可以兼容一下
from prequest.
请求库层面兼容不了,因为本质上是通过 success 和 fail 回调函数,来判断请求成功与否,如果 Taro.request 没有响应,请求库层面就会认为一直处于请求的过程中。。这个只能给 Taro 提 RP 了
from prequest.
Related Issues (20)
- Module '"@prequest/lock"' has no exported member 'createLockWrapper'. HOT 9
- Taro v3.2.10 请求锁报错 HOT 6
- 文档不详细 HOT 3
- [bug] use-request 返回data错误 HOT 3
- `useRequest`类型定义 HOT 1
- 还是uniapp 缓存的问题, HOT 4
- await 如何获取promise rejection ? HOT 2
- Taro中使用 '@prequest/lock'刷新 Token,TS一直提示错误
- 1.3.6 bugs? HOT 12
- ios 9 : ReferenceError: Can't find variable: Proxy __ERROR HOT 5
- about xhr responseType... HOT 11
- cache 插件的 缺陷 HOT 10
- createAsyncPromise @xdoer/x 只在dev分支才有这个静态方法,已发版的还没有这个静态方法 HOT 9
- export declare type RetryControl = (opt: PQRequest, err: PQError) => boolean; HOT 2
- 从1.4升级到1.5之后, 无法导入PQResponse类型 HOT 1
- 类型不全 HOT 1
- 在Taro 3.4.2 版本编译报错 HOT 1
- lock的getValue使用 undefined判断
- 请求payload 序列化问题? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prequest.