diff options
author | Ernst Widerberg <ernstwi@kth.se> | 2021-10-15 14:44:17 +0200 |
---|---|---|
committer | Ernst Widerberg <ernstwi@kth.se> | 2021-10-15 14:44:17 +0200 |
commit | 40500d46b8a9724a54dc4be6be027d49aa610b56 (patch) | |
tree | e686889b6d857b1634f24a3fd8a2ea9ceb8421f7 /src | |
parent | 46fc6263d0f93506927f572591e301f615186413 (diff) |
Update ObjectView getData
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ObjectView.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/components/ObjectView.js b/src/components/ObjectView.js index 08951c0..3b39c96 100644 --- a/src/components/ObjectView.js +++ b/src/components/ObjectView.js @@ -22,14 +22,22 @@ class ObjectView extends React.Component { Authorization: "Basic " + btoa("user1:pw1") } }) - .then(resp => resp.json()) + // TODO: Look at `status` or return code or both? .then(resp => { - // TODO: Look at `status` or return code or both? - if (resp.status != "success") - throw `soc_collector responded: ${resp.status}`; - return resp.data; + if (resp.status !== 200) + throw `Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}`; + this.setState({ + totalPages: resp.headers.get("X-Total-Count") + }); + return resp.json(); + }) + .then(json => { + if (json.status != "success") + throw `Unexpected status from soc_collector: ${json.status}`; + this.setState({ + object: json.data + }); }) - .then(object => this.setState({ object: object })) .catch(e => this.props.setError(e)); } |