我正在努力寻找离子原生 http 问题的解决方案。
我尝试了这篇文章的答案,但我仍然遇到同样的错误
这是我的代码
switchToggle(){
let url = 'https://io.adafruit.com//api/v2/myusername/feeds/my-feed-id/data/';
const headers = new Headers();
headers.set("Content-Type", "application/json")
headers.set("X-AIO-Key", "PASTED_MY_KEY_HERE");
let data = {
"datum":{
"value" : 1
}
};
this.http.setDataSerializer('json');
this.http.post(url,data,{headers:headers})
.then(data => {
console.log(data);
}).catch(error => {
console.log(error)
});
}
这是我得到的错误
当我尝试其他没有标题的发布请求时,它工作正常。但是对于这个特定的 API,我需要将请求与标头一起发送。