GithubHelp home page GithubHelp logo

Comments (4)

chenjsh36 avatar chenjsh36 commented on August 22, 2024 2

umi-request 默认对状态码为 200 的请求自动根据响应类型做序列化处理和解析,返回后台对应的值,如果状态码非 200,则会走 errorHandler ,用户可以在 errorHandler 里对响应做对应的处理,详情可参考文档,如果不需要自动处理可通过 parseResponse 关闭处理简化,并通过中间件自定义响应处理方式。

from umi-request.

leftstick avatar leftstick commented on August 22, 2024

你的response是怎么打印出来的?

from umi-request.

kelefun avatar kelefun commented on August 22, 2024

你的response是怎么打印出来的?

截图是代码里的 console.log(reponse) 打印出来的

//dva somecode 
 effects: {
    *signin({ payload }, { call, put }) {
      const response = yield call(login, payload);
      console.log(response)

--
目前看来应该跟返回状态码有点关系
刚刚测试了下如果返回状态码=200 打印出来的就是后台返回的值,

from umi-request.

artemdumanov avatar artemdumanov commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.