Below I will bring you an example of the front-end obtaining the return value of http status code 400. Let me share it with you now and give it as a reference for everyone.
is as follows:
axios.get("/check_mobile_and_sent_code",{withCredentials:true,params:{mobile:formInline.mobile}}).then(res=>{ console.log(res); //if(res.result==true){ if (!this.timer) { this.count = this.TIME_COUNT; this.show = false; this.timer = setInterval(() => { if (this.count > 0 && this.count <= this.TIME_COUNT) { this.count--; } else { this.show = true; clearInterval(this.timer); this.timer = null; } }, 1000) } //} }).catch(error=>{ console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); console.log('Error', error.message); console.log(error.config); })
Usage scenario:
When the backend determines that the verified mobile phone number already exists 400 will be returned. At this time, you need to jump to the error condition and get the return data of background 400 as above.
The following is the return value of error.response:
If error is output directly here, it is equal to error.message
The attached status code is 200 The return value:
#The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
JavaScript memory leak problem in versions before IE9 (detailed summary)
In design mode The application of facade appearance pattern in JavaScript development (advanced)
Tutorial on the use of combination pattern in JavaScript design pattern development (advanced)
The above is the detailed content of The front-end obtains the return value example of http status code 400_Basic Tutorial. For more information, please follow other related articles on the PHP Chinese website!