在请求头中添加Content-Type和Accept,并将请求数据转换为JSON字符串格式。
示例代码:
axios({
method: 'post',
url: 'http://example.com',
data: {name: 'John'},
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
.then(response => console.log(response))
.catch(error => console.log(error));
上一篇:axios没有得到响应
下一篇:Axios没有发送会话数据