当前位置:网站首页>From client to server

From client to server

2022-06-24 23:18:00 13 less

When we send a request , From client to server , What have you experienced ?

One . Considerations for invoking interfaces

Our focus is on the requested address , Requested method ,tokne, Request header , Requested parameters , Request type , These things can be seen in the console . When our request fails , Don't rush to the back end , First determine whether the address of your request is correct , The requested method is incorrect , And the transfer of parameters , When there is no problem, the data is still unavailable , We can ask questions before it's too late , Always keep the interface document handy for easy viewing .

(1) See the position of parameters

 
(2) Where the response data is

  Both of them can see the returned data

(3) The requested method and address

(4) Request header

It's storing token And some information that contains the request

Two .x-www-form-urlencoded and form-data and raw The difference between

Position of being :

3、 ... and . Status code returned by the server

Usually, the front-end call is accompanied by the back-end status code , To determine whether the data has been returned successfully , And whether the operation was successful .

Common status codes :

2xx    Return to success Or the operation is successful

3xx    Represents the redirection problem  

4xx  Parameter error weight insufficient Parameter error

5xx  The server crashed

(1) I have talked about Dang in previous articles token When it fails, the user does not have permission to access it ,token When it fails

Status code from 2xx  become 4xx  Insufficient authority , You can do something at this time token Treatment of failure . The status code is not fixed, but can be set by the backend

(2) When to return to 2xx When

It indicates that the request or operation is successful . Interface call successful .

原网站

版权声明
本文为[13 less]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241706349008.html