-
Notifications
You must be signed in to change notification settings - Fork 25
Deleting
DavidDuwaer edited this page Sep 22, 2017
·
6 revisions
You can delete a model, e.g. artist
of type Artist
, by writing
artist.delete()
Deleting an object returns a promise, and a DeleteResponse
is passed to the callback you register on this promise. For example
artist
.delete()
.then(function(DeleteResponse response) {
let deleted: boolean = response.isSuccess();
});
The DeleteResponse
only has the isSuccess
method. It is therefore only useful when you are not using a catch
clause or when the underlying API is not following the JSON API standard in all cases. I.e. when you are writing
artist
.delete()
.then(function(DeleteResponse response) {
// ending up here for a JSON API means the deletion was successful
let deleted = response.isSuccess(); // will always be true
})
.catch(function () {
// ending up here means the deletion was unsuccessful
});
then DeleteResponse
contains no extra information, as any unsuccessful deletion would in a proper JSON API always result in an HTTP error response.