Здравствуйте, можна как-то замапить внутри мапа?
Например:
Я получаю от сервера данные:
{
"cod": "200",
"message": 0,
"cnt": 40,
"list": [
{
"dt": 1585342800,
"main": {
"temp": 278.63,
"feels_like": 272.5,
"temp_min": 278.63,
"temp_max": 279.68,
"pressure": 1024,
"sea_level": 1024,
"grnd_level": 1021,
"humidity": 66,
"temp_kf": -1.05
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"clouds": {
"all": 3
},
"wind": {
"speed": 5.84,
"deg": 34
},
"sys": {
"pod": "n"
},
"dt_txt": "2020-03-27 21:00:00"
},
{
"dt": 1585353600,
"main": {
"temp": 278,
"feels_like": 272.53,
"temp_min": 278,
"temp_max": 278.79,
"pressure": 1025,
"sea_level": 1025,
"grnd_level": 1022,
"humidity": 71,
"temp_kf": -0.79
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"clouds": {
"all": 2
},
"wind": {
"speed": 4.99,
"deg": 32
},
"sys": {
"pod": "n"
},
"dt_txt": "2020-03-28 00:00:00"
},
{
"dt": 1585364400,
"main": {
"temp": 277.73,
"feels_like": 272.12,
"temp_min": 277.73,
"temp_max": 278.25,
"pressure": 1025,
"sea_level": 1025,
"grnd_level": 1022,
"humidity": 71,
"temp_kf": -0.52
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"clouds": {
"all": 3
},
"wind": {
"speed": 5.13,
"deg": 27
},
"sys": {
"pod": "n"
},
"dt_txt": "2020-03-28 03:00:00"
},
{
"dt": 1585375200,
"main": {
"temp": 277.96,
"feels_like": 271.91,
"temp_min": 277.96,
"temp_max": 278.22,
"pressure": 1026,
"sea_level": 1026,
"grnd_level": 1023,
"humidity": 70,
"temp_kf": -0.26
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"clouds": {
"all": 2
},
"wind": {
"speed": 5.76,
"deg": 35
},
"sys": {
"pod": "d"
},
"dt_txt": "2020-03-28 06:00:00"
},
{
"dt": 1585386000,
"main": {
"temp": 281.52,
"feels_like": 274.82,
"temp_min": 281.52,
"temp_max": 281.52,
"pressure": 1027,
"sea_level": 1027,
"grnd_level": 1024,
"humidity": 56,
"temp_kf": 0
},
"weather": [
{
"id": 802,
"main": "Clouds",
"description": "scattered clouds",
"icon": "03d"
}
],
"clouds": {
"all": 31
},
"wind": {
"speed": 6.76,
"deg": 40
},
"sys": {
"pod": "d"
},
"dt_txt": "2020-03-28 09:00:00"
}
}
Эти данные я передаю в компонент в объект weather
const weat = {}
weather.list.map(day => {
const num = new Date(day.dt * 1000).getDate()
if (num in weat) {
weat[num].push(day)
} else {
weat[num] = [day]
}
})
Далее я их сортирую по дню, и получаю такой объект