欢迎来到万象站长学堂!

CSS/HTML

当前位置: 主页 > 网络编程 > CSS/HTML > 文章列表

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

时间:2026-02-09 13:20:52|栏目:CSS/HTML|点击:58 次

如下所示:

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

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

附状态码为200的返回值:

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

上一篇:

栏    目:CSS/HTML

下一篇:高德地图WEB版基础控件展示[原创]

本文标题:前端获取http状态码400的返回值实例

本文地址:https://zhanzhang.eapis.site/html/17410.html

您可能感兴趣的文章

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:120507403 | 邮箱:120507403@qq.com

Copyright © 2002-2025 万象站长学堂 版权所有沪ICP备2021023961号-8 粤公网安备 13010202004186