I am calling an API and I stored its data in a local variable then also I am unable to access the data. On accesing I get the output as "undefined"
let arrOfAPI = new Map();
let i = 0;
fetch("https://www.kontests.net/api/v1/all")
.then(res => res.json())
.then(data => data.forEach(elem => {
arrOfAPI.set(i++ , elem)
}));
console.log(arrOfAPI.get(23));