首页 > 其他分享 >【解决】axios 下载文件 Failed to read the 'responseText' property from 'XMLHttpRequest'

【解决】axios 下载文件 Failed to read the 'responseText' property from 'XMLHttpRequest'

时间:2023-04-28 16:00:12浏览次数:51  
标签:axios XMLHttpRequest read Failed responseText property

主要解决以下两个问题

问题一:idm一些网站不允许请求同一文件两次

故障原因:IDM 在发神经

因为它检测到浏览器集成插件未安装,所以诱导你安装。实际上,装了插件问题也会出现。改参数都没用。

1.很可能是你点击网页的 下载链接 有问题(换个网页下载试试,就不提示了),Edge 浏览器一直会欺骗你, Google 浏览器偶会欺骗你。⇒ 如果开发项目,检查后端接口正常

问题二:Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'blob').
at r.onreadystatechange (http://cdn.staticfile.org/axios/0.1.0/axios.min.js:2:1004)

2.也可能是前端 请求工具 出了问题。比如请求工具

// post、put、patch 等请求
axios.post(url, {...someData}, {responseType: 'blob'})
    .then((res) => {
        //...
    }).catch((err) => {
        //
    })

故障原因:排查一个早上,也参考了 Github 一些仓库的代码,在另一个项目也正常用的,这个语法没有问题。最后才发现,是 axios 版本太 TM 老了。

<!--<script src="//cdn.staticfile.org/axios/0.1.0/axios.min.js"></script>-->
<script src="//cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.min.js"></script>

更新到 1.3.6 ,网页点击下载,就正常了。IDM也不报错。
response数据模型

标签:axios,XMLHttpRequest,read,Failed,responseText,property
From: https://www.cnblogs.com/miozus/p/17362446.html

相关文章

  • STM32 + RTThread + UGUI
    一、概述开发板:STM32F103C8T6显示器:ST7735SRT-Thread:5.0.0玩过GUI的小伙伴都知道,界面的显示是一个个像素点组合起来的,那么直接构建出来炫酷的GUI还是相对比较困难的,所以我们一般都会使用一些GUI库来实现,比如LVGL、QT、UGUI等,这样对于驱动开发的人员来说就相对比较简......
  • Linux shell script read file line by line All In One
    LinuxshellscriptreadfilelinebylineAllInOneLinuxshell脚本逐行读取文件Ijustwanttoreplacethegrepcommand,andfilterouttherealIPaddress192.168.18.195withnativeshellsyntax.#!/usr/bin/envbashIPs=$(ifconfig|grep-oE'192\.168......
  • 【TypeScript】document.body.style TS 报错 Cannot assign to 'style' because it is
    报错信息解决方法style对象提供了一个cssText属性,支持设置多种CSS样式:document.body.style.cssText=`width:${targetX}px;height:${targetY}px;transform:scale(${scaleRatio})translateX(-50%);left:50%`;还有其他方法也可以,参考下面的文章参考文章七爪源码:使用......
  • Python很多时候要从键盘连续输入一个数组,并用空格隔开;Python爬取一些数据;python pip安
    Python要从键盘连续输入一个数组,并用空格隔开,Python中的实现方法如下:str=input(‘以空格为间隔连续输入一个数组:’)然后在键盘中输入,会·得到的str为一个字符串,要将其转为一个列表有两种方法方法一:a=[int(n)forninstr_in.split()]方法二:a=list(map(int,str.strip().sp......
  • 控制台报错:[Vue warn]: Error in render: "TypeError: Cannot read properties of nu
    可能原因在调取接口获取返回值时,由于各种原因(参数错误、返回格式不规范等),导致接收返回时数据类型与初始值不同。data(){return{list:[]//原本是个数组对象}},methods:{getList(){letparams={}apiRequest(params).then(r......
  • 使用Axios下载Nignx文件,并重命名
    需求:因为下载的nginx的文件地址是UUID组成的,要下载呢就需要用axios。然后结合我上一篇文章,把nginx的跨域打开。http://localhost:8085/project_1/2023/04/27/C9E9CC592AF849F7BFA025F16E2271BD.sqlhttps://www.cnblogs.com/pphboy/p/17360526.htmlexportfunctiondownloadFil......
  • TypeError: Cannot read properties of undefined (reading 'filter')
    TypeError:Cannotreadpropertiesofundefined(reading'filter')constfilterTableData=computed(()=>store.data.users!.filter((data)=>!search.value||data.nick.toLowerCase().includes(search.value......
  • JS通过axios提交application/x-www-form-urlencoded类型的数据
    使用axios提交类型为application/x-www-form-urlencoded数据的正确姿势:letformData=newURLSearchParams()formData.append('param1',param1)formData.append('param2',param2)axios({url:'http://xxx.xxx.xxx.xxx/xxx',method:'......
  • 使用axios下载文件
    使用axios下载文件/***下载文件*@param{string}url下载地址*@param{string}fileName文件名,例:1.png*/exportfunctiondownload(url,fileName){axios({url:url,method:'GET',responseType:'blob',}).then((r......
  • How to use axios.js instead of request.js to get data as a buffer All In One
    Howtouseaxios.jsinsteadofrequest.jstogetdataasabufferAllInOne如何使用axios.js代替request.js获取数据作为缓冲区questionconstfs=require("fs");varpath=require("path");const{exit}=require("process");//requ......