Home > database >  Can't get data from fetched array
Can't get data from fetched array

Time:12-11

have a mongo database which holds a short list of events with some extra data. The data is returned and sent to the App. This all goes swimmingly. Inside the App I want to extract titles foreach array element, but when i try use or foreach loop the output is undefinded.

** data i get from api:** {status: 'ok', evnets: Array(1)} evnets: Array(1) 0 {title: 'r', descryption: 'asd', StartDate: '2022-12-16 13:51', EndDate: '2022-12-29 09:52', _id: '63944787606e1280f2e14cde'}

I tried:

foreach()

 data.events.forEach(element => {
Title = data.events.title
    
  });

CodePudding user response:

I think the returned data from the API is evnets not events

  • Related