简体   繁体   中英

Browser get request 404'd but works with Postman app

Title says it all, trying to retrieve some data with the openweather api.

It works fine on Postman, however when using vanillaJS in a local environment I get an error message in console

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.

Try axios.get('http://api.openwheather...') and it should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM