前端獲取http狀態(tài)碼400的返回值實(shí)例
如下所示:
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); })
使用場景:
當(dāng)后端判斷驗(yàn)證的手機(jī)號已存在的時(shí)候會返回400,這時(shí)需要跳到error條件中,得到后臺400的返回?cái)?shù)據(jù)如上。
以下是error.response返回值:
這里如果直接輸出error,等于error.message
附狀態(tài)碼為200的返回值:
以上這篇前端獲取http狀態(tài)碼400的返回值實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持我們。
上一篇:沒有了
欄 目:CSS/HTML
下一篇:css列表標(biāo)簽list與表格標(biāo)簽table詳解
本文標(biāo)題:前端獲取http狀態(tài)碼400的返回值實(shí)例
本文地址:http://mengdiqiu.com.cn/a1/CSS_HTML/11484.html
您可能感興趣的文章


閱讀排行
本欄相關(guān)
- 04-02html5算法,html5協(xié)議
- 04-02html5圖形,html5圖形縮放
- 04-02html5登錄模板,html5登錄注冊模板
- 04-02html5的例子,HTML示例
- 04-02html5的canvas,html5的canvas的作用
- 04-02關(guān)于html5 視頻代碼的信息
- 04-02html5chm手冊,html操作手冊
- 04-02朋友圈html5,朋友圈發(fā)泄情緒的句子
- 04-02html5的新特性有哪些,HTML5的新特性有哪
- 04-02html5掃二維碼,html5調(diào)用手機(jī)攝像頭掃描
隨機(jī)閱讀
- 01-10delphi制作wav文件的方法
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 04-02jquery與jsp,用jquery
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05織夢dedecms什么時(shí)候用欄目交叉功能?