简体   繁体   English

如何访问 7 天和每小时的 OpenWeatherMap 数据?

[英]How to access 7 day and per hour OpenWeatherMap data?

I'm creating a weather app using the openweathermap API.我正在使用openweathermap API 创建一个天气应用程序。

If the user enters the site then show the weather data of 7 days in the form of cards.如果用户进入网站,则以卡片的形式显示 7 天的天气数据。

But if the user clicks on one card of weather then show the data of the particular day per hour.但是,如果用户点击一张天气卡片,则每小时显示特定日期的数据。

To get 7 days of data I'm using this code:要获得 7 天的数据,我正在使用以下代码:

axios
    .get(
        "https://api.openweathermap.org/data/2.5/forecast?q={CITY_NAME},{COUNTRY_CODE}&appid={API_KEY}&cnt=7"
    )
    .then((data) => {
        console.log(data.data);
    });

From this I'm getting the 7 day data.从这里我得到了 7 天的数据。 But how can I get per day/hour data using this API?但是如何使用这个 API 获取每天/每小时的数据?

Looking at the docs you need to call the endpoint at forecast/hourly to get hourly weather data.查看文档,您需要在forecast/hourly调用端点以获取每小时天气数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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