【发布时间】:2021-12-02 18:28:55
【问题描述】:
无论如何我可以解决这个错误吗?我试过把“”也放在请求头中,但它不起作用
对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。
axios.post("https://platform.fatsecret.com/rest/server.api?food_id=33691&method=food.get.v2&oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d&oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245126631&oauth_version=1.0",{
})
.then(response=>{
console.log(response.data);
}
)
.catch(error=>{
alert("wrong");
console.log(error)
})
【问题讨论】:
-
在 SO 上搜索,您会发现很多类似的问题与完全相同的问题/错误
-
fatsecret.com/rest/server.api不允许直接嵌入他们的数据。
标签: javascript axios