I am working on a COVID tracker web app with React. I have modified the JSON data fetched from an api according my needs. But when I test by looping over it it doesn't show up anything. And when I tried to log it into my console it shows empty and undefined for the elements in the array.
Here is the code I used to fetch the data
const districts = [];
const fetchedData = fetch(
    "https://api.covid19india.org/state_district_wise.json"
)
    .then((res) => res.json())
    .then((data) => {
        for (let district in data["Tamil Nadu"].districtData) {
        
                districts.push(
                    // obj["district"] = [district];
                    data["Tamil Nadu"].districtData[district],
                );
      districts.map((districtName)=>{
        districtName.district = district
      })
        }
    });
// for (var key in districts) {
//   console.log(key);
// }
 console.log(districts) 
     
    