I started getting in to the concept of async sometime ago, but I am having some problems...
So this code basically does some queries to find out which dates are not available for bookings, using a for loop(line 31) for 30 days(30 loops).
For each loop:
Once it reaches to line 67, it now knows if a date is available by checking the totalcount of the query.
If it is 0(Line 69) it gets the previous blocked dates of the datepicker, and adds the new blocked date to that(lines 71,72,73)
I tried several ways of using async but I'm not sure I have found the correct one...
Once it reaches to line 72 I had a console.log to print the var dt(which is the current loop date)
I get 2 logs, 3th of September, and 4th of September.
That is wrong.The dates with no availability is 1th and 2nd. So I am guessing the date goes to the next loop and it logs the new loop date...or something like that...
I've been trying to solve this for hours now and I just can't figure out what is going on...
Can someone help?
I tried giving an 60ms delay within the loops (line 32,33,34) and line 78 but doesn't seem to fix the problem.