diff options
| author | Ernst Widerberg <ernstwi@kth.se> | 2021-10-13 08:30:25 +0200 |
|---|---|---|
| committer | Ernst Widerberg <ernstwi@kth.se> | 2021-10-13 08:30:25 +0200 |
| commit | 65a5b255d0b3d35ca9908b42f81ed50099308557 (patch) | |
| tree | f9a1d45fb3aad58178c39870a41967fd0cf6b43c /src/components/ObjectView.js | |
| parent | 443c2e1ab711962b6f657f97c86c5cac7b39c6c6 (diff) | |
Update Object view for backend changes, and fix setError
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() { |
