search

Home  >  Q&A  >  body text

angular.js - Which method of api interface returns data is the best experience? ? ?

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中文网2793 days ago509

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-15 17:06:30

    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

    reply
    0
  • Cancelreply