function createTownslist() {
let towns = ["Sudak", "Yalta", "Kerch", "Feodosiya"];
return Promise.all(
towns.map(town => fetch(`https://api.weatherbit.io/v2.0/current?city=${town}&key=ced73555abfb464ebcb5d7e77f5be270`)
.then(res => res.json())
.then(json => json.data))
)
.then(response => {
return towns.reduce((acc, town, i) => {
acc[town] = response[i]
return acc
}, {})
})
}
// createTownslist().then(towns => console.log(Object.keys(towns), towns));
(async function () {
const towns = await createTownslist()
console.log(Object.keys(towns), towns)
})()
надо разбираться с асинхронность ) ЯП
https://medium.com/@stasonmars/%D0%B...it-ba5f47f4436