Article From:https://segmentfault.com/q/1010000015622870
Question:

In the design of the back-end interface, for example, in the front end separation, for example

{
    "code":1,
    "data":{}
}

codeThe value of 1 indicates whether the request is successful or should the code request fail? See several demo, all is to set 0 to succeed. How did you make it?

Answer 0:

I decided that the 0 set for success is mainly because the C function returns 0, which means successful execution. You can also set 200 as a success, just like HTTP status.

Answer 1:

It is best to follow the response status of HTTP to mark the status with 200400.
https://developer.mozilla.org…

Leave a Reply

Your email address will not be published. Required fields are marked *