【发布时间】:2017-09-07 04:00:28
【问题描述】:
我正在尝试使用 axios 从我的 express 应用调用另一个服务(也尝试过 node-fetch)
所以,当我使用 curl、soapui 或 swagger 调用服务时,它可以工作。
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '"02"' 'http://example.com/api/v1/something'
但是当我尝试使用
axios.put('http://example.com/api/v1/something', '"03"')
.then((response) => {
res.sendStatus(200);
})
.catch((error) => {
console.log(error);
res.sendStatus(500);
});
我收到“请求失败,状态码 415”
【问题讨论】:
-
这就是我的想法,所以我检查了 jsonlint.com 上的“03”是否是有效的 JSON。