I need to call a function that returns the current date. I have to call this function in an object (contained in the body of my query). This object has a property whose value is the current date.
I wrote the function code as follows in the "pre-request scripts" of a POST request:
function currentDate() {
let currentDate = new Date();
return formatDate(currentDate);
};
function formatDate(date) {
return [date.getFullYear(), date.getMonth() + 1, date.getDate()].map(n => n < 10 ? `0${n}` : `${n}`).join('-');
};
Here is the property of the object in the body of my request:
Here is the error I get in console:
Thanks for your help