The understanding of the value 1 or 0 of "code" in the json returned by the backend interface.

in the separation of front and rear ends, and in the design of back-end interfaces, such as

{
    "code":1,
    "data":{}
}
The value of

code, 1 means that the request succeeded or failed in response to the code request? Look at several demo, is set 0 as successful. How do you make it?


this had better follow the response status of http to indicate the status
https://developer.mozilla.org.


. The reason why 0 is set to success is mainly because the c function returns 0 means successful execution, which is a problem left over by history. You can also set 200 to succeed, just like http status.

Menu