【发布时间】:2019-12-20 12:52:13
【问题描述】:
标题说明了一切,尝试使用 openweather api 检索一些数据。
它在 Postman 上运行良好,但是在本地环境中使用 vanillaJS 时,我在控制台中收到错误消息
ERROR: GET http://127.0.0.1:5500/api.openweathermap.org/data/2.5/forecast?id=2193733&appid=MYAPIKEY 404 (Not Found)
我的代码是这样的
axios.get(`api.openweathermap.org/data/2.5/forecast?id=2193733&appid=MYAPIKEY`)
.then(response => {
console.log(response);
})
有什么想法吗?
【问题讨论】:
-
网址中缺少协议。查看请求在您的错误中的去向。它会发送到您的服务器而不是 api
标签: javascript html browser axios postman