const fromDate = moment();
const toDate = moment().subtract(6, 'days');
const enumerateDaysBetweenDates = (startDate, endDate) => {
let foundDates = [];
while (endDate.isSameOrBefore(startDate)) {
foundDates.push(`${endDate.format("YYYY-MM-DD")}`);
endDate.add(1, "days");
}
return foundDates;
};
const results = enumerateDaysBetweenDates(fromDate, toDate);
console.log("results: ", results);