[web教学] vue 封装的axios接口,请求接口动态增加headers&responseType

[复制链接]
查看980 | 回复0 | 2023-8-23 11:37:49 | 显示全部楼层 |阅读模式 来自 中国北京
一、碰到一个需求,掉接口的时间,给headers中添加一个参数

  1. // 调试日志下载
  2. export const getDebug  = (params) => {
  3.         const uploadaxios = axios.create({
  4.                 headers:{
  5.                         'Range':'bytes=0-'
  6.                 },
  7.                 responseType: 'blob'
  8.         })
  9.         return uploadaxios.get(`/device_maintenance/file_get`, {params} ).then(res => res.data);
  10.        
  11. };
  12. // 可以加一个参数吧headers传进来
复制代码


来源:https://blog.csdn.net/weixin_53587375/article/details/129727863
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则