mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(image): display a valid error message when deleting an image (#149)
fix(image): display a valid error message when deleting an image
This commit is contained in:
parent
7c2047cfbf
commit
4d99c12215
1 changed files with 8 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue