Comments (4)
umi-request 默认对状态码为 200 的请求自动根据响应类型做序列化处理和解析,返回后台对应的值,如果状态码非 200,则会走 errorHandler ,用户可以在 errorHandler 里对响应做对应的处理,详情可参考文档,如果不需要自动处理可通过 parseResponse 关闭处理简化,并通过中间件自定义响应处理方式。
from umi-request.
你的response
是怎么打印出来的?
from umi-request.
你的
response
是怎么打印出来的?
截图是代码里的 console.log(reponse) 打印出来的
//dva somecode
effects: {
*signin({ payload }, { call, put }) {
const response = yield call(login, payload);
console.log(response)
--
目前看来应该跟返回状态码有点关系
刚刚测试了下如果返回状态码=200 打印出来的就是后台返回的值,
from umi-request.
To be honest I was so irritated with umi library experience since it's impossible to find an answer to your question or if there is an answer in Chinese. I am strongly convinced that umi community should be using English more extensively as the word does.
After 3 hours I've managed the issue. Here is the concrete recipe.
export const errorHandler = error => {
const { response, data } = error;
response.data = data
return response
}
from umi-request.
Related Issues (20)
- 如何取消警告
- config set [redirect: 'manual']
- POST request with base64 image HOT 1
- 是否支持路径参数
- 能否实现像useRequest一样的对于同一个请求 请求多次默认只保留最后的请求结果
- Request 搞那么麻烦干嘛?简化呢?
- 好好的axios让你们封装成了依托答辩,真的是服了 HOT 1
- 请求成功还是触发了timeout
- stream类型支持吗 HOT 1
- 用在小程序上可以吗 HOT 5
- 1
- 1
- How to use RequestConfig based on @umijs/max to make the front end insensitive to refresh tokens
- 使用vite,在修改页面后,接口出现errorHandler.ts:37 TypeError: response.clone is not a function的报错,但是刷新一下页面报错就没了,请问是什么原因
- 引用链接失效
- 我试图在RequestConfig中修改headers的Content-Type,可这样始终无法生效 HOT 1
- 不使用umi全家桶单独使用umi-request 如何使用mock.js 拦截请求? HOT 1
- 请求设置 requestType: 'form' 无效 HOT 1
- umi-request在next.js中可以使用吗?
- 请求时怎么配置忽略SSL校验 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 umi-request.