我尝试将数据与邮递员上的api一起发送,但可以,但不适用于axios。我想知道如何在代码中添加标头。
var ticket = {
road: e.state.road,
amount: e.state.amount,
day: e.state.day,
mon: e.state.mon,
pay: e.state.pay,
card: e.state.card,
cvc: e.state.cvc,
holdername: e.state.holdername,
phone: e.state.phone,
pin: e.state.pin,
nic: e.state.nic,
email: e.state.email,
}
axios.post('http://localhost:8080/ticket', ticket).then(function(response) {
e.setState({
messageFromServer: response.data
});
});
答案 0 :(得分:1)
使用您的API检查cors政策,Postman不会检查cors。
示例:https://www.npmjs.com/package/cors用于NodeJS API