- 添加头部headers
// 新创建 axios 实例配置
const $axios = axios.create({
baseURL: 'http://domain.com',
timeout: 5000,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'sessionId': Lockr.get("sessionId"),
'authKey': Lockr.get("authKey"),
}
}); - 参数序列化
var qs = require('qs');
axios.post('/foo', qs.stringify({ 'foo': 'bar' });
见 https://github.com/mzabriskie/axios/blob/master/README.md#using-applicationx-www-form-urlencoded-format