const httpServer = (opts, data) => {
const token = localStorage.getItem('token')
const PUBLIC = `?token=${token}`
let httpDefaultOpts = ''
var host = `${process.env.HOST}`
var prot = `${process.env.PORT}`
var base = host +(prot?":"+prot:"")
if (opts.method === 'post') {
httpDefaultOpts = {
method: opts.method,
url: `${base}${opts.url}${PUBLIC}`,
headers:{
'Content-Type':'application/text/html;charset=utf-8' //改这里就好了
},
data: data
}
} else {
httpDefaultOpts = opts
}
return new Promise(function (resolve, reject) {
Axios(httpDefaultOpts).then(
(res) => {
successState(res)
resolve(res)
}
).catch(
(err) => {
errorState(err)
reject(err)
}
)
})
}
VUE项目axios请求头更改Content-Type
const httpServer = (opts, data) => {const token = localStorage.getItem('token')const PUBLIC = `?token=${token}`let httpDefaultOpts = ''var host = `${process.env.HOST}`...
·
转载于:https://www.cnblogs.com/lml-lml/p/9316948.html
更多推荐
已为社区贡献1条内容
所有评论(0)