首页 > 其他分享 >解决AxiosError: options must be an object ERR_BAD_OPTION_VALUE

解决AxiosError: options must be an object ERR_BAD_OPTION_VALUE

时间:2022-10-28 21:45:14浏览次数:65  
标签:AxiosError OPTION ERR object options must

VUE中HTTP请求,AxiosError: options must be an object ERR_BAD_OPTION_VALUE 错误解决。

 

此错误完整为:

{message: 'options must be an object', name: 'AxiosError', code: 'ERR_BAD_OPTION_VALUE', stack: 'AxiosError: options must be an object\n at Objec…ji.com/static/js/chunk-libs.c096185b.js:42:41367)'}

 

产生产错误的原因为:

axios版本升级导致,0.x升级为1.x,在请求参数数组序列化时出现

 

解决方法:

修改前:

    paramsSerializer: function(params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }

 

修改后:

    paramsSerializer: { 
      serialize:function(params) {
       return Qs.stringify(params, { arrayFormat: 'repeat' })
     }
    }

 

标签:AxiosError,OPTION,ERR,object,options,must
From: https://www.cnblogs.com/yzeng/p/16837606.html

相关文章