diff options
Diffstat (limited to 'src/components/ObjectView.js')
| -rw-r--r-- | src/components/ObjectView.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/components/ObjectView.js b/src/components/ObjectView.js index 4a04c93..e6556c1 100644 --- a/src/components/ObjectView.js +++ b/src/components/ObjectView.js @@ -23,13 +23,16 @@ class ObjectView extends React.Component { } }) .then(resp => resp.json()) + .then(resp => { + // TODO: Look at `status` or return code or both? + if (resp.status != "success") + throw `soc_collector responded: ${resp.status}`; + return resp.data; + }) // TODO: Proper API call to get single object .then(data => data.filter(x => x._id == this.props.id)[0]) - // .then(data => { - // console.log(data); - // return data; - // }) - .then(object => this.setState({ object: object })); + .then(object => this.setState({ object: object })) + .catch(e => this.props.setError(e)); } render() { |
