Array Returns Length Of 0 Although It Has Values
so i am trying to push items to an array and it appears to be return a length of 0 although there are items in the array. let calendarDates = [] async function getDates() { c
Solution 1:
This will help
asyncfunctionMain() {
let calendarDates = []
calendarDates = awaitgetDates();
createCalendar(date, side)
}
asyncfunctiongetDates() {
const response = awaitfetch('/calendars/fetch_dates')
returnawait response.json();
}
functioncreateCalendar(date, side) {
console.log('createCalendar', calendarDates, "is array?", Array.isArray(calendarDates), 'length', calendarDates.length);
}
Main();
Post a Comment for "Array Returns Length Of 0 Although It Has Values"