前端獲取http狀態(tài)碼400的返回值案例-創(chuàng)新互聯(lián)

前端獲取http狀態(tài)碼400的返回值案例?這個(gè)問題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見到的。希望通過這個(gè)問題能讓你收獲頗深。下面是小編給大家?guī)?lái)的參考內(nèi)容,讓我們一起來(lái)看看吧!

成都創(chuàng)新互聯(lián)公司于2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元全南做網(wǎng)站,已為上家服務(wù),為全南各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108

如下所示:

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返回值:

前端獲取http狀態(tài)碼400的返回值案例

這里如果直接輸出error,等于error.message

附狀態(tài)碼為200的返回值:

前端獲取http狀態(tài)碼400的返回值案例

感謝各位的閱讀!看完上述內(nèi)容,你們對(duì)前端獲取http狀態(tài)碼400的返回值案例大概了解了嗎?希望文章內(nèi)容對(duì)大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站制作公司行業(yè)資訊頻道。

當(dāng)前題目:前端獲取http狀態(tài)碼400的返回值案例-創(chuàng)新互聯(lián)
文章源于:http://bm7419.com/article46/hsdhg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、企業(yè)建站、網(wǎng)站營(yíng)銷、網(wǎng)站導(dǎo)航小程序開發(fā)、App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)