我正在尝试向 api.weatherstack.com 发出 GET 请求(请参阅文档)。
这是我的反应效果挂钩:
useEffect(() => {
if (country === undefined) return
console.log(country.name)
axios
.get('http://api.weatherstack.com/current', {
params: {
access_key: api_key,
query: country.name
}
})
.then(response => {
console.log(response.data)
setWeather(response.data)
})
}, [api_key, country])
但是,每次我运行它时,我都会收到此错误:
{ 代码:105,类型:“https_access_restricted”,信息:“访问受限 - 您当前的订阅计划不支持 HTTPS 加密。” }
通过我的浏览器或 Postman 进行 API 调用非常有效,所以我认为我使用 React 或 Axios 的方式可能存在问题。
此外,这个 API 调用大约有 10% 的时间有效,所以我对为什么也会发生这种情况感到困惑。