fix(image): display a valid error message when deleting an image (#149)

fix(image): display a valid error message when deleting an image
pull/154/head
Anthony Lapenna 8 years ago committed by GitHub
parent 7c2047cfbf
commit 4d99c12215

@ -6,14 +6,18 @@ function jsonObjectsToArrayHandler(data) {
return angular.fromJson(str);
}
// Image delete API returns an array on success and an object on error.
// This handler creates an array from an object in case of error.
// Image delete API returns an array on success and a string on error.
// This handler creates an array composed of a single object with a field 'message'
// from a string in case of error.
function deleteImageHandler(data) {
var response = angular.fromJson(data);
if (!Array.isArray(response)) {
var response;
if (!Array.isArray(data)) {
var arr = [];
response = {};
response.message = data;
arr.push(response);
return arr;
}
response = angular.fromJson(data);
return response;
}

Loading…
Cancel
Save