I’m using react to send date to server but there is an error
{message: ‘Invalid date format. Date should be in the format YYYY-MM-DD.’, field: ‘from’}
I’m completely sure the data is valid and here is the code
const handleFilter = async (e) => {
e.preventDefault();
console.log(fromDate);
console.log(toDate);
try {
const date = {
from: dayjs(fromDate).format("YYYY-MM-DD"),
to: dayjs(toDate).format("YYYY-MM-DD"),
};
console.log(date);
const res = await newRequest.get("/analysis", date);
console.log(res);
} catch (error) {
console.log(error);
}
};
and there is the console
I’m tried a lot of answers like
JSON.stringify(date);
before sending
nothing work !!!