mirror of https://github.com/embarklabs/embark.git
same for destroy
This commit is contained in:
parent
ae4c16a47a
commit
f1f258b8f9
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue