umi-request
umi-request copied to clipboard
A request tool based on fetch.
I put the following configuration in app.tsx, console always output {} which I expect extending response data with my customize data, but it doesn't work. What should I do to...
我在文档上看到有下面这个用法 修改response响应头,但是这个response.header是只读的包括type,status,url 等几个属性都是只读,我把下面这段代码拿出来试了一下 确实报错TypeError。当我把response.headers.append('interceptors', 'yes yo');去掉又正常,文档上描述用append添加头如果没有遵守header的这个规范就会触 发TypeError,因为我试的时候失败了,我想问一下真的可以这样用么,或者是其他问题导致的 `// response interceptor, chagne response request.interceptors.response.use((response, options) => { response.headers.append('interceptors', 'yes yo'); return response; }); `
` import { extend } from 'umi-request'; const RequestTask = new Map() const controller = new AbortController(); // 创建一个控制器 const { signal, abort } = controller; // 返回一个 AbortSignal 对象实例,它可以用来...
OnionMiddleware 的 next 应该是返回一个 Promise,这样在 ts 中 await 时就不会提示`'await' has no effect on the type of this expression.ts(80007)`
umi-request不能自动将 cookie中的 CSRF 令牌自动添加的 Headers 中。 将 cookies 中的 CSRF 令牌 XSRF-TOKEN 自动添加到 Request 的 Headers 中很有必要的。 Angular 和 Axios 都会自动加入。 谢谢。
对于 `content-type: multipart/form-data` 的请求,需要删除请求头里的 `content-type`,让浏览器自己去添加,否则会由于未包含 `boundary` 信息,导致上传失败 见: - https://github.com/umijs/umi-request/issues/98 - https://muffinman.io/uploading-files-using-fetch-multipart-form-data/
当使用拦截器时,这个请求的promise永远不会resolve,或reject 版本: 6.9.4 ``` import request from 'umi-request'; request.interceptors.response.use(async (response) => { return response; }); request({url: ‘实际请求数据60k左右'}) ```