Hello I have an application that creates an object which holds a Date variable. The object is then passed into an http update function. Unfortunately, the update when it goes through everything looks great except the date is reset to 2018-06-06T04:00:00 instead of the actual time that was added. for testing purposes I ran the update query separately with the same object payload and it went through fine so I know is not the api. Any ideas what I could be doing wrong?
item in JSON used for payload:
{"id":10, "name":"test", "description":"test description", "startDate":"2018-06-06T23:30:00.000Z", "endDate":"2018-06-07T02:30:00.000Z"}
Code:
app.config(function($routeProvider, $resourceProvider, $httpProvider) {
$httpProvider.defaults.headers.common = {Accept: "application/json, text/plain, */*"};
//other code to set up routes, also added an interceptor to verify the data been sent, this is where I was able to see the data's Date time is reset.
});
//function to update
function updateObj(item){
$http.put(urlToApi, item, {headers:{'Content-Type': 'application/json', 'Accept': 'application/json'}})
.then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
console.log("ERROR: " + response);
});
}