Created
January 7, 2015 17:19
-
-
Save gregturn/403b5e34e2dce9de1d19 to your computer and use it in GitHub Desktop.
cujo rest DELETE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rest({method: 'DELETE', path: item._links.gallery.href}) | |
| .done(function() { | |
| findLinkedItem(item).remove(); | |
| $('#images ul').append(createItemRow(item)); | |
| }); |
Author
Thanks. For some reason, Spring Data REST stopped handling this delete operation, but I didn't realize it because the follow function, which moved the item in the DOM happened anyway. I'll try it out.
Author
Ahh. Nice! Well, taken that, I think I found something perfect for my situation:
item.clientFor('gallery')({method: 'DELETE'})
.done(function(response) {
if (response.status.code >= 200 && response.status.code < 300) {
findLinkedItem(item).remove();
$('#images ul').append(createItemRow(item));
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By default, if the request is completed and a response is received, the promise success handler will be invoked, network errors will trigger the error handler.
You can change this behavior based on the status code with the
rest/interceptor/errorCodeinterceptor, by default >=400 are treated as errors, but you can configure it.As an aside, it looks like your trying to perform an operation on a related resource, if the 'item' was returned with HAL, you can instead do something like:
Using
clientForsimply created a client for the href defined by the relationship. You can then invoke the client like any other. Templated hrefs will be expanded as well.