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)
}
)
})
}