[英]Browser get request 404'd but works with Postman app
Title says it all, trying to retrieve some data with the openweather api.标题说明了一切,尝试使用 openweather api 检索一些数据。
It works fine on Postman, however when using vanillaJS in a local environment I get an error message in console它在 Postman 上运行良好,但是在本地环境中使用 vanillaJS 时,我在控制台中收到一条错误消息
ERROR: GET http://127.0.0.1:5500/api.openweathermap.org/data/2.5/forecast?id=2193733&appid=MYAPIKEY 404 (Not Found)
My code looks like this我的代码看起来像这样
axios.get(`api.openweathermap.org/data/2.5/forecast?id=2193733&appid=MYAPIKEY`)
.then(response => {
console.log(response);
})
Any ideas?有任何想法吗?
You are getting the request Sent on top of your app that's running axios.您正在运行 axios 的应用程序顶部收到发送的请求。
Try axios.get('http://api.openwheather...')
and it should work尝试
axios.get('http://api.openwheather...')
它应该可以工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.