文章詳情頁
前端獲取http狀態(tài)碼400的返回值實(shí)例
瀏覽:218日期:2022-06-02 18:11:14
如下所示:
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); })
使用場(chǎng)景:
當(dāng)后端判斷驗(yàn)證的手機(jī)號(hào)已存在的時(shí)候會(huì)返回400,這時(shí)需要跳到error條件中,得到后臺(tái)400的返回?cái)?shù)據(jù)如上。
以下是error.response返回值:
這里如果直接輸出error,等于error.message
附狀態(tài)碼為200的返回值:
以上這篇前端獲取http狀態(tài)碼400的返回值實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持。
相關(guān)文章:
1. spring集成httpclient配置的詳細(xì)過程2. SpringBoot 改造成https訪問的實(shí)現(xiàn)3. Java commons-httpclient如果實(shí)現(xiàn)get及post請(qǐng)求4. Android webview加載https鏈接錯(cuò)誤或無響應(yīng)的解決5. Java發(fā)送http請(qǐng)求的示例(get與post方法請(qǐng)求)6. java HttpClient傳輸json格式的參數(shù)實(shí)例講解7. Java實(shí)現(xiàn)基于http協(xié)議的網(wǎng)絡(luò)文件下載8. 關(guān)于springboot 中使用httpclient或RestTemplate做MultipartFile文件跨服務(wù)傳輸?shù)膯栴}9. PHP使用Http Post請(qǐng)求發(fā)送Json對(duì)象數(shù)據(jù)代碼解析10. spring boot 常見http請(qǐng)求url參數(shù)獲取方法
排行榜
