После недельного эксперимента
я нашел решение
, которое я расширил его внутри графика.
после того, как я вставил данные в кэш.
APRegisterExt GetAPExtension = APGraph.Document.Current.GetExtension<APRegisterExt>();
Этот трюк работает для меня. Спасибо за ваше предложение! :)
Вы можете использовать setInterval, чтобы ограничить частоту выполнения кода, например
setInterval(function(){
if (props.city) {
useEffect(() => {
fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
).then(data => setWind(data.wind.speed))
})
useEffect(() => {
fetch(`https://api.worldweatheronline.com/premium/v1/weather.ashx?key=a5bf94fc16c84928acb114156182311&q=${props.city}&num_of_days=1&tp=24&format=json`).then(results => {return results.json();}
).then(data => setPrecipitation(data.data.weather[0].hourly[0].chanceofrain))
})
useEffect(() => {
fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
).then(data => setPressure(data.main.pressure))
})
useEffect(() => {
fetch(`https://api.openweathermap.org/data/2.5/weather?q=${props.city}&units=metric&APPID=af081727ae6d5c4cbe2cd266b726e632`).then(results => {return results.json();}
).then(data => setHumidity(data.main.humidity))
})}}, 10000);
, а затем просто настроить время для проверки того, как часто вы хотите его проверять