{console.log(res);//if(res.r" />

百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>html5教程> 前端猎取http状态码400的返回值实例_根基教程
分享文章到:

前端猎取http状态码400的返回值实例_根基教程

发布时间:09/01 来源:未知 浏览: 关键词:
下面我就为大家带来一篇前端猎取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返回值:

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

附状态码为200的返回值:

上面是我整理给大家的,但愿今后会对大家有帮忙。

相关文章:

JavaScript在IE9此前版本中内存泄露问题(具体总结)

设计模式中的facade外不雅模式在JavaScript开发中的使用(高级篇)

JavaScript设计模式开发中组合模式的使用教程(高级篇)

以上就是前端猎取http状态码400的返回值实例_根基教程的具体内容,更多请关注百分百源码网其它相关文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有150人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板