使用
可以通过向 axios 传递相关配置来创建请求
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
// 发送 POST 请求
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});
</script>
设置header
axios({
method: "POST",
url: `${API_HOST}/api/bind/index`,
data: {
firstName: 'Fred',
lastName: 'Flintstone'
},
headers: {
'key': 'value'
}
}).then(function(res) {
console.log(res);
});