0

So when when my axios request posts to my server it is converting my req header to a string. So if I console.log(data) I get the following... enter image description here

And then when I console.log(req.body) from my server I get...

 { title: 'test 2',
  start: '2018-10-13T05:00:00.000Z',
end: '2018-10-13T05:00:00.000Z',
color: 'blue' }

Why is it converting my start and end to a String? And how do I keep it as the Date object?

Edit

Axios Post

   export const addEvent = eventData => dispatch => {
      console.log(eventData);
      dispatch(setEventsLoading());
      axios
        .post("/api/events/", eventData)
...
Snoopy
  • 1,257
  • 2
  • 19
  • 32

1 Answers1

1

When you get result from the server it will return the data as JSON. JSON doesn't know anything about dates as you can read here [The "right" JSON date format. All you can do is convert the data returned into date. You can use library like moments to covert string into date format

aldilas
  • 36
  • 4
  • I was thinking I was going to have to do that. I wasn't sure if I could change how the headers are sent. Thanks! – Snoopy Oct 12 '18 at 03:09