After receiving data from an API in the 'yyyy-MM-dd' format, I encountered a display issue when trying to convert it to 'dd-MM-yyyy'. How can I properly adjust the date format without disrupting the table display?
onMounted(async () => {
const today = startOfDay(new Date());
const lastWeek = sub(today, { days: 7 });
const searchParams: TableSearchParams = {
startDate: format(lastWeek, 'yyyy-MM-dd'),
};
const { data } = await fetchData(searchParams);
if (data && data.entries) {
tableRows.value = data.entries.map((entry) => ({
...entry,
lastDelivery: entry.values ? entry.values[entry.values.length - 1].date : '-',
}));
} else {
tableRows.value = [];
}
});