Closed exejutable closed 9 years ago
You can refer to the restheart blog example web application that uses $http.
(We have also restheart notes example that uses restangular.)
Looking at edit.js, you'll find:
$http.defaults.headers.common["If-Match"] = $scope.post._etag.$oid;
This is how the If-Match request header is set.
In your case try (I haven't tried it)
< .. ng-click="deleteMember(member)">
//Delete member
$scope.deleteMember = function (member){
$http.defaults.headers.common["If-Match"] = member._etag.$oid;
$http.delete(member._links.self.href)
.success(function (data, status) {
// success callback
})
.error(function (data, status) {
// error callback
});
};
In case the client tries to update a member that has been already updated by another client since it loaded it, it will get 412 Precondition Failed. If you want to force to overwrite it, reload the resource in the error callback and invoke deleteMember recursively.
Thanks ujibang, works excelent !!!
I want to delete a member in my app . I cannot make DELETE work with ETag. I've never used it, sorry! I did this
Html
Javascript
Response 412 (Precondition Failed)
I need some help.