您好我有一个应用程序,它创建一个包含Date变量的对象。然后将该对象传递给http更新函数。不幸的是,除非将日期重置为2018-06-06T04:00:00而不是添加的实际时间,否则更新时所有内容看起来都很棒。出于测试目的,我使用相同的对象有效负载单独运行更新查询,它经历了很好,所以我知道不是api。我有什么想法可能做错了吗?
用于有效载荷的JSON项:
{“id”:10,“name”:“test”,“description”:“test description”,“startDate”:“2018-06-06T23:30:00.000Z”,“endDate”:“2018 -06-07T02:30:00.000Z“}
代码:
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);
});
}