美文网首页
给axios改变header为application/x-www

给axios改变header为application/x-www

作者: cytheria19900 | 来源:发表于2020-08-17 16:42 被阅读0次

直接这么改是没有用的

axios.defaults.headers.post["Content-Type"] =

  "application/x-www-form-urlencoded";

需要引入qs,然后转码,qs是axios自带可直接使用

import Qs from 'qs'

然后把参数转码

export function selectDAppointmentTimeList(params) {

console.log('查看参数', params)

return request({

url: '/v1/patient/selectDAppointmentTimeList',

method: 'post',

data:Qs.stringify(params)

})

}

当然,也可以直接在拦截器里拦截

config.data = Qs.stringify(config.data)

相关文章

网友评论

      本文标题:给axios改变header为application/x-www

      本文链接:https://www.haomeiwen.com/subject/yipqjktx.html