{console.log(res);//if(res.result==tr ;更新日期:2025/5/7,杰网资源,站长资源网,CPU天梯,显卡天梯,UU加速器,阅读3.0,英雄联盟,怪物猎人,成人身份证号大全2023,实名认证,王者荣耀,绿色地狱合成表,,2022年防沉迷身份证,qq飞车紫钻,序列号,破解版,注册机,绿色版,互联网资源,福利资源,网络流行语,高清电影,韩剧美剧,Q币活动,Q钻活动,动漫资讯,游戏教程,LOL资讯视频,CF活动大全,LOL最新活动,CF实用技巧,DNF活动资讯,和平精英,技术教程,SEO教程,QQ教程,网络教程,下载中心,破解软件,游戏软件,网站源码,易语言源码,安卓软件,QQ软件,汉化版,无损音乐,MKV,WAV+CUE,FLAC,HQCD,MP3,SACD,DSD,抖音,720P,1080P,2160P,2K,4K高清,320k,度盘,百度云盘,蓝奏,微云盘,网盘,无广告纯净版,不限速下载,去广告,修改器,VIP解析">

前端获取http状态码400的返回值实例

网络编程 发布日期:2025/5/7 浏览次数:1

正在浏览:前端获取http状态码400的返回值实例

如下所示:

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);
          })

使用场景:

当后端判断验证的手机号已存在的时候会返回400,这时需要跳到error条件中,得到后台400的返回数据如上。

以下是error.response返回值:

前端获取http状态码400的返回值实例

这里如果直接输出error,等于error.message

附状态码为200的返回值:

前端获取http状态码400的返回值实例

以上这篇前端获取http状态码400的返回值实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。