GithubHelp home page GithubHelp logo

Comments (2)

wanchun avatar wanchun commented on July 29, 2024

出现提示接口错误的原因:
FesApi默认的响应接口如下:

this.FesApi.setResponse({
     successCode : "0",
     codePath : "code",
     messagePath : "msg",
     resultPath : "result"  
});

而这次请求的响应内容为{"status":"you are logged in"} 。

FesApi解析到的业务码为undefined,不等于设置的业务成功状态码“0”,判断本次请求为失败,而且未找到错误消息,就提示了默认错误信息。

接口请求的状态分为两种:
1、http状态码
2、业务状态码
只有http状态码为2xx和业务状态码为successCode时,接口调用才表示为成功。

例如创建用户请求:
如果校验用户账号不符合要求,这时候可以定义错误码“-1”,返回错误消息“用户名不符合规范”。

{ code: "-1", msg: "账号不符合规范", result: {   } }

业务码是比较通用的做法,建议加上。

除此之外,FesApi从响应结果中解析出resultPath对应的内容,在then函数中返回。

from fes.js.

textproofreading avatar textproofreading commented on July 29, 2024

@wanchun

多谢说明,已经调试通过了。

from fes.js.

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.