Полный скрипт: < /p>
Код: Выделить всё
window.onload = () => {
const target = document.getElementById('forecast');
const aeris = new AerisWeather('', '');
const request = aeris.api().endpoint('forecasts').place('sunnyside,wa').filter('daynight').limit(1).skip(0);
request.get().then((result) => {
const data = result.data;
const { periods } = data[0];
if (periods) {
periods.reverse().forEach(period => {
const date = new Date(period.dateTimeISO);
const precip = period.weatherPrimary || 'Unknown';
const pop = period.pop || '0';
const code = period.weatherCoded.wx;
const html = (`
${precip.includes('Smoke') ? `${pop > 15 ? `Areas of Smoke with a
Chance of ${code}` : `Areas of Smoke`}` : `${code}`}
`);
target.insertAdjacentHTML('afterbegin', html);
});
}
});
}
< /code>
Эта часть я пытаюсь отобразить объекты в рамках WeatherCoded.wx < /p>
Раздел скрипта: < /p>
const code = period.weatherCoded.wx;
< /code>
api json return (пример 1): < /p>
"weatherCoded": [
{
"timestamp": 1757422800,
"wx": "S::T,S:L:RW",
"dateTimeISO": "2025-09-09T08:00:00-05:00"
},
{
"timestamp": 1757430000,
"wx": "C:L:RW,S::T",
"dateTimeISO": "2025-09-09T10:00:00-05:00"
},
{
"timestamp": 1757440800,
"wx": "C::T,C:L:RW",
"dateTimeISO": "2025-09-09T13:00:00-05:00"
},
{
"timestamp": 1757448000,
"wx": "S::T,S:L:RW",
"dateTimeISO": "2025-09-09T15:00:00-05:00"
},
{
"timestamp": 1757451600,
"wx": "C::T,C:L:RW",
"dateTimeISO": "2025-09-09T16:00:00-05:00"
}
],
< /code>
api json return (пример 2): < /p>
"weatherCoded": [],
< /code>
api json return (пример 3): < /p>
"weatherCoded": [
{
"timestamp": 1757419200,
"wx": "PA::F",
"dateTimeISO": "2025-09-09T07:00:00-05:00"
},
{
"timestamp": 1757451600,
"wx": ":VL:RW",
"dateTimeISO": "2025-09-09T16:00:00-05:00"
}
],
< /code>
он попробовал ... < /p>
const code = period.weatherCoded[1].wx;
Подробнее здесь: https://stackoverflow.com/questions/797 ... of-objects