Code Monkey home page Code Monkey logo

Comments (2)

yanzhenjie avatar yanzhenjie commented on August 24, 2024

请看这个方法的JavaDoc,这个方法的意思是Http层面的请求成功,表示请求途中没有发生任何问题,和服务器通信成功。http的状态码有很多,200段、300段、400段、500段都可能是成功,服务器可以自定义这些状态码的,你所说的成功是你们业务的成功,所以需要你自己根据你们服务器约定的成功状态码来判断是否真正的成功,比如我们服务器约定的响应码是200才是成功,我是这样做的:

if(response.responseCode == 200) {
    ...
}

这里建议你看下ReadMe中NoHttp自定义请求的介绍,在onParseResponse方法中解析数据,并做状态码的判断,可以封装返回适合自己的业务的数据,在那里解析数据失败了可以抛出一个异常,NoHttp会自动回调onFailed()方法的。当然你也可以在每个onSucceed()中判断服务器数据返回是否正确(一般是解析数据的时候正确解析说明格式、数据都正确)。

from nohttp.

mundane799699 avatar mundane799699 commented on August 24, 2024

行, 那我以后就用responseCode来判断了

from nohttp.

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.