axios请求失败,如何获取接口返回的状态码及错误信息
如果axios请求失败,如何获取接口返回的状态码及错误信息?
方法如下
axios.get('api/test').then((res) => {console.log(res)).catch((error) => {if (error.response) {// The request was made and the server responded with a status code// that falls out of the range of 2xxconsole.log(error.response.data);console.log(error.response.status);console.log(error.response.headers);} else if (error.request) {// The request was made but no response was received// `error.request` is an instance of XMLHttpRequest in the browser and an instance of// http.ClientRequest in node.jsconsole.log(error.request);} else {// Something happened in setting up the request that triggered an Errorconsole.log('Error', error.message);}console.log(error.config);});
axios请求失败,如何获取接口返回的状态码及错误信息相关推荐
- axios请求失败,response.data返回的状态码及错误信息获取
axios请求失败,后端接口返回的状态码及错误信息获取 使用封装的elementUI后台框架,后台框架自定义封装并返回的code码转态(全部的返回数据,如下所示): 浏览器查看:返回的 error 信 ...
- vue 下载文件流和捕获后端返回的状态码和错误信息的方法
文件流下载需要注意的是 responseType: 'blob' ,否则下载的文件不能正确打开.但是当数据库返回400时,捕获不到error的错误信息,因为responseType设置了固定的返回格式 ...
- python网页查询然后返回结果_python(30) 获取网页返回的状态码,状态码对应问题查询...
获取访问网页返回的状态码 html = requests.get(Url) respon= html.status_code 以下内容来自于维基百科:点击查看网页 1xx消息 这一类型的状态码,代表请 ...
- 根据地址获取HTTP返回的状态码
通过php来获取http返回的状态玛,如下函数 function GetHttpStatusCode($url){$curl = curl_init();curl_setopt($curl,CURLO ...
- 微信接口返回的状态码
'-1' => '系统繁忙,此时请开发者稍候再试', '0' => '请求成功', '40073' => '不合法的 cardid', '40009' => '图片文件超长.' ...
- curl获取http返回的状态码
方式一 curl -I -s -m 10 http://192.158.1.11:8080/test/ |grep HTTP|awk '{print $2}' 方式二 curl -I -o /dev/ ...
- 解析json格式请求返回500状态码的异常
异常描述: (1)响应信息: (2)请求信息: (3)服务器中解析json所依赖的类的信息以及处理请求的逻辑 class Bedroom {public String desk;public Stri ...
- axios发送post请求返回400状态码
axios发送post请求返回400状态码 今天在用 axios 发送一个跨域的post请求时,遇到了一个坑:Uncaught (in promise) Error: Request failed w ...
- get请求400错误 vue_解决axios发送post请求返回400状态码的问题
今天在用 发送一个跨域的post请求时,遇到了一个坑:uncaught (in promise) error: request failed with status code 400. 前台代码如下: ...
- python获取状态码_Python 如何获取接口返回的http状态码
使用request 模块得到返回值,然后再利用status_code属性获取http响应的状态码. 示例代码: import requests import json url = 'http://de ...
最新文章
- 二层交换配置完ping失败_设置完端口聚合之后就ping不通了!!!
- 《c语言从入门到精通》看书笔记——第5章 常用的数据输入输出函数
- wireshark数据包分析实战 第三、四章
- 谁能主宰服务器市场?Linux 之父和 Redis 之父有分歧了
- Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间取摸
- jquery插件实现分页
- 【Unity3D开发小游戏】《太空射击游戏》Unity开发教程
- win7修复计算机卡了,win7升级到win10后突然很卡的修复方法(图文)
- 利用批处理文件快速设置IP地址
- 使用Amazon SageMaker RL 和Unity训练强化学习智能体
- 去除word转pdf时的图片黑边
- C语言家谱管理程序,[C语言]家谱 - 代码贴 - BCCN
- vbnet加载ocx控件不能生成窗体_解决VB6.0中不能加载MSCOMCTL.OCX的错误提示
- Linux之ant安装部署
- rust 使用tokio的Notify 和timeout实现类似可超时条件变量的效果
- Python基础学习备忘录上
- linux字体配置要略,Linux字体配置要略.pdf
- mybatis由浅入深day02_4多对多查询_多对多查询总结
- ElementPlus之封装分页器
- 如何将一个python文件打包成一个可执行的小程序