Guard against a null value for the HostVolumes hash

When a node has no host volumes, the API response will
have a null value for the HostVolumes attribute, which
in turn becomes a null value instead of an empty array
in the store. This protects against that, ensuring host
volumes is always an array.
This commit is contained in:
Michael Lange
2020-03-26 09:54:52 -07:00
parent c452a8954e
commit 5f2de59773
2 changed files with 29 additions and 4 deletions

View File

@@ -17,10 +17,8 @@ export default ApplicationSerializer.extend({
return assign({}, drivers[key], { Name: key });
});
if (hash.HostVolumes) {
const hostVolumes = hash.HostVolumes;
hash.HostVolumes = Object.keys(hostVolumes).map(key => hostVolumes[key]);
}
const hostVolumes = hash.HostVolumes || {};
hash.HostVolumes = Object.keys(hostVolumes).map(key => hostVolumes[key]);
return this._super(modelClass, hash);
},