From 65a5b255d0b3d35ca9908b42f81ed50099308557 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Wed, 13 Oct 2021 08:30:25 +0200 Subject: Update Object view for backend changes, and fix setError --- src/components/ObjectView.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/components/ObjectView.js') 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() { -- cgit v1.1