summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ObjectView.js20
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));
}