Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

request 支持 GBK 编码 #718

Open
PeachScript opened this issue Apr 28, 2022 · 5 comments
Open

request 支持 GBK 编码 #718

PeachScript opened this issue Apr 28, 2022 · 5 comments
Assignees

Comments

@PeachScript
Copy link
Member

参考:https://github.com/umijs/umi-request/blob/master/src/utils.js#L83

@migodev42
Copy link
Contributor

看了下 request.tpl 的实现感觉有点问题

const getRequestInstance = (): AxiosInstance => {

intercepter 是在同一 axios 实例中共享的。
在所有请求都是串行的情况下,request 上设置的 iterceptor 才在单个请求中生效。
而当请求并行时,可能出现某个 request 上的 iterceptor 覆盖掉其他请求的原本逻辑

比如下面这个例子,第一个请求的 iterceptor 会把后一个请求的 url 也改为 /api/hack
image

image

@migodev42
Copy link
Contributor

这种是否需要提示下用户,不能直接在 request 上去配置 iterceptor。只能 1. 在 app.ts 中定义全局的 iterceptor 2. 新增透出一个 axios.create 的口子,在自己新建的实例上去添加 iterceptor。

@migodev42
Copy link
Contributor

另外我想尝试支持下 gbk 编码转换问题 🙋🏻‍♂️

@YdreamW
Copy link
Contributor

YdreamW commented May 12, 2022

在 app.ts 中定义全局的 iterceptor 2. 新增透出一个 axios.create 的口子,在自己新建的实例上去添加 iterceptor。

这个问题我们后面会调研讨论一下,是否有必要提供 ‘’给单独某次 request 请求添加拦截器 ‘’ 的功能。

@YdreamW
Copy link
Contributor

YdreamW commented May 12, 2022

另外我想尝试支持下 gbk 编码转换问题 🙋🏻‍♂️

欢迎!(* ̄︶ ̄) 可以直接提 pr

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

No branches or pull requests

3 participants