Skip to content

Commit

Permalink
fix(models): Added hack to support malformed response object returned…
Browse files Browse the repository at this point in the history
… by page loader
  • Loading branch information
atruskie committed Dec 1, 2016
1 parent 077ce43 commit 3cdbb3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/models/associations.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ angular
throw new Error("This static method must be called with a bound this");
}

// dirty hack: the multi-pager loader sends through an array of responses
// TODO: remove this and fix the pager!
let canonicalResponse = response.responses && response.responses[0] || response;

if ((canonicalResponse.headers("content-type") || "").indexOf("application/json") < 0) {
throw new Error(`The request ${canonicalResponse.config.method} ${canonicalResponse.config.url} does not contain a JSON response`);
}

var items = [];
if (angular.isArray(response.data.data)) {
//noinspection JSUnresolvedVariable
Expand All @@ -203,7 +211,7 @@ angular
}

// allow all object to get and set their meta data object
let meta = response.data.meta;
let meta = canonicalResponse.data.meta;

// setup capabilities

Expand Down

0 comments on commit 3cdbb3e

Please sign in to comment.