I'm trying to make a simple loop, so I can log the data in the console:
const demands = data.myDemand;
console.log(demands);
//First approach
demands.map((demand) => {
console.log(demand);
});
//Second approach
Array.prototype.forEach.call(demands, (demand) => {
console.log(demand);
});
Using the first approach I receive the following error:
TypeError: demands.map is not a function
And the second approach just displays nothing. What could be the problem? Logging the whole demands data in the console, I receive this output:
The general Idea is that I want to map this data that's coming from the backend to the props in the current react component but I am not able to get the mapping to works since I need to go through this array of objects, in which some of the objects also contain array of objects...