I have an Array and I would like to acquire the following data into variables. How this can be done. I’m really new to React and would like to know how to do this too.
My Array
I want to get the following information and My array’s name is EventInformation
const movieId = 0
const movieDate = 0
const showtimeId = 0
const venueId = 0
>Solution :
First of all the main thing in the screenshot is an object, not an array. The name of the object isn’t given either, but you should know since you printed it to console. I’ll just use myObj for the name.
Const movieId = myObj.movieId;
Const movieDate = myObj.venueInfo[0].date;
Const showtimeId = myObj.venueInfo[0].venues[0].showtimes[0].showtimeId;
Const venueId = myObj.venueInfo[0].venues[0].venueId;
This is hard-coded to only get the value of the first venu. The venues were made into an array for a reason so I would suggest making a loop through all the venues if there is more than one venu you want.
