Skip to content

Commit

Permalink
Fix base fetcher for generic elements
Browse files Browse the repository at this point in the history
  • Loading branch information
beque committed Feb 3, 2023
1 parent bb577d4 commit 768dd97
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/packs/src/fetchers/BaseFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export default class BaseFetcher {
addQuery = type === 'generic_elements' ? `&el_type=${queryParams.name}` : '';
return fetch(api.concat(addQuery), {
credentials: 'same-origin'
}).then(response => (
response.json().then(json => ({
elements: json[type].map(r => (new ElKlass(r))),
totalElements: parseInt(response.headers.get('X-Total'), 10),
page: parseInt(response.headers.get('X-Page'), 10),
pages: parseInt(response.headers.get('X-Total-Pages'), 10),
perPage: parseInt(response.headers.get('X-Per-Page'), 10)
}))
}).then((response) => (
response.json().then(json => ({
elements: (type === 'generic_elements' ? json.map(r => (new ElKlass(r))) : json[type].map(r => (new ElKlass(r)))),
totalElements: parseInt(response.headers.get('X-Total'), 10),
page: parseInt(response.headers.get('X-Page'), 10),
pages: parseInt(response.headers.get('X-Total-Pages'), 10),
perPage: parseInt(response.headers.get('X-Per-Page'), 10)
}))
)).catch((errorMessage) => { console.log(errorMessage); });
}
}

0 comments on commit 768dd97

Please sign in to comment.