18910140161

JavaScript-如何获取打开的天气地图API-堆栈溢出

顺晟科技

2022-10-18 13:22:27

10

我的Open Weather Map API在Postman上运行良好,但在浏览器上获取它时出现错误。

邮递员党卫军

//fetching weather api
    async getWeather() {
        console.log("efsfs");
        const response = await fetch('api.openweathermap.org/data/2.5/weather?q=London&appid=3f071776be6f7ccd417bfb1da2910---');
        const responseData = await response.json();

        return responseData;
    }
//Using it
weather.getWeather()
    .then(results => {
        console.log(results)
    })
    .catch(err => console.error(err));
//Error
weather.js:11 GET http://127.0.0.1:5500/api.openweathermap.org/data/2.5/weather?q=London&appid=3f071776be6f7ccd417bfb1da2910859 404 (Not Found)

顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航