same for destroy

This commit is contained in:
Jonathan Rainville 2018-09-06 14:42:51 -04:00 committed by Pascal Precht
parent ae4c16a47a
commit f1f258b8f9
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 8 additions and 3 deletions

View File

@ -31,13 +31,18 @@ function post(path, params = {}) {
});
}
function destroy(path, params) {
function destroy(path, params = {}) {
const callback = params.callback || function(){};
return axios.delete(constants.httpEndpoint + path, params)
.then((response) => {
return {response, error: null};
const data = (response.data && response.data.error) ? {error: response.data.error} : {response, error: null};
callback(data.error, data.response);
return data;
})
.catch((error) => {
return {response: null, error: error.message || 'Something bad happened'};
const data = {response: null, error: error.message || 'Something bad happened'};
callback(data.error, data.response);
return data;
});
}