1. When the API interface returns data or returns an error message, the user is prompted with some relevant information, such as a form submission such as illegal parameters, and then a prompt that the form submission is successful. When I succeed in the background, all returns are uniform. success However, the front-end directly prompted success to the user, which led to the leader saying that Chinese characters such as success should be directly returned to the background. I was speechless. Can't the front-end define a set of information to be returned to the user? You have to use the backend to return. Our backend returns all the error codes. The prompt information plus the error code is only used for viewing when it is open to quickly locate errors, but the front end directly prompts the user to see it. Can you guys give me some advice?
If you can do it, just do what the leader says. If you can’t do it, just tell the front-end what the leader says and run away...
First of all, the front-end should impose certain format restrictions on the input content, and make an illegal prompt before submission, and it cannot be submitted;
The back-end usually makes a regular HTTP error code. After the front-end and the back-end agree on this error code, the prompt information will be output It is done by the front-end, the front-end and back-end are separated and can be modified flexibly;
For example, the back-end returns 200, and the front-end receives 200 and prompts a prompt like XXXXX success
Generally, the front-end does not involve logical judgment and is only responsible for display. Maybe you can return it like this:
That’s okay.
When I wrote the interface in the past, I returned the relative path of the image. I was also thinking that if the front end spliced the domain name and the relative path, wouldn't it be a complete path? But it will increase the complexity of the front end.
You just have to talk to the two front-end guys about this. It has nothing to do with the boss. What the boss wants is the final result. It’s up to you to decide how to do it. Just communicate with the final standards and what the final standards will be. You can talk to the front-end brothers. Let's talk like this. I will pass the code, status, and data data to you. You only need to judge the code and status. You will return relevant prompts and data data. All successes will be xxx, and failures will be xxx. Otherwise, every interface will transmit Chinese characters. , it’s a pain in the ass for you to judge on the front end.
I usually return the status code from the interface. Then understand the meaning of the status code in the interface document. That’s ok
Maybe your leaders don’t understand technology at all.
In principle, the back-end should not transmit server information to the front-end, but it doesn’t matter if it’s just a success or failure prompt. Tell the front-end students about where they went wrong, and they can communicate with you.