标题说明了一切,尝试使用 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);
})
有什么想法吗?
最佳答案
您正在收到在运行 axios 的应用程序之上发送的请求。
尝试 axios.get('http://api.openwheather...')
它应该可以工作
关于javascript - 浏览器收到 404 请求,但可与 Postman 应用程序一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57486652/