Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send javascript date object with POST request in REST CLIENT (vs code extension)?

I want to make a post request using REST CLIENT extension in VS Code.

Here's the screenshot

How can I send javascript new Date() object or moment() or dayjs() objects with the request?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried changing Content-type: application/javascript but it didn’t work. Please suggest some solution. Thank you.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading