I am having an issue in accessing the object through key which got set dynamically with in a loop.
Setting Data in an object as follows:
let carddata = await cardresult.json(); // es6 promise data
memberDataObject[item.id] = {
cards: carddata,
boardName: item.name
}
Following is my Console Log of memberDataObject
I am trying to access data as follows:
console.log(MemberDataObject['5a8a9d6305e9658367740bb7']);
What I want: I want to access the data by key in a loop which is an id of other data array. somthing like this :
memberBoards.boards.map( (boarditem,key) => {
let data = MemberDataObject[boarditem.id];
console.log(data);
})
But console.log(data)
is giving undefined
in console.log but instead I expect the array to be printed.
Notes: I am running this code in ReactJS, following ES6 with EsLint and Babel.
I have googled around and found other answers in StackOverflow but nothing works. I might be missing something very minor.