I want to make a post request using REST CLIENT extension in VS Code.
How can I send javascript new Date()
object or moment()
or dayjs()
objects with the request?
I tried changing Content-type: application/javascript
but it didn't work. Please suggest some solution. Thank you.
CodePudding user response:
JSON is a plain text data-interchange format and it has no built-in date/time type.
You need to format the date as a string. ISO8601 is usually used:
new Date().toISOString();
moment().toISOString();
dayjs().toISOString();
It should look like: 2023-01-20T12:17:00Z
.
Then the endpoint should parse it.