angular.js - Which method of api interface returns data is the best experience? ? ?
PHP中文网
PHP中文网 2017-05-15 17:04:30
0
1
514

api interface:
1 Use Status Code to return whether it is an error (business and non-business error)
Such as 422 unprocessable entity - used when verifying errors. Only errors will return errors message prompt information
Success 200 body only returns data carrier such as:
name
age
address

2 All normal and error apis return 200 and then return business error codes, data, etc. in the body.
sucess
code
data

The first benefit of using is that it is easy to judge. Many frameworks such as angular react's http requests integrate success and error processing.
The second kind of expansion is convenient and can prevent Chinese operators from illegally interfering with non-200

A group of friends said: Don’t use any Status Code on the external network. The operator is shameless. 4xx and other things will be hijacked.

Has anyone encountered a situation where the API interface was hijacked without using https?

Which plan is better according to your own understanding?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
巴扎黑

Let me first talk about the format of the json data returned by our API:

code: 0 means success - 100 parameter error - 200 business processing failed
msg: detailed error reason
data: data returned by the interface
There has not been any hijacking by the operator yet
Android and IOS mobile apps use http call There will be no cross-domain issues with the interface

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template