From 46b9df3279f51479cfc607cbce8fb8b73bef69f7 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Wed, 6 Oct 2021 16:11:06 +0200 Subject: Initial commit --- src/components/ObjectView.js | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/components/ObjectView.js (limited to 'src/components/ObjectView.js') diff --git a/src/components/ObjectView.js b/src/components/ObjectView.js new file mode 100644 index 0000000..4a04c93 --- /dev/null +++ b/src/components/ObjectView.js @@ -0,0 +1,46 @@ +import React from "react"; + +import ObjectComponent from "./ObjectComponent"; + +class ObjectView extends React.Component { + constructor(props) { + super(props); + this.state = { + object: null + }; + + this.getData = this.getData.bind(this); + } + + componentDidMount() { + this.getData(); + } + + getData() { + fetch("http://localhost:8000/sc/v0/get", { + headers: { + Authorization: "Basic " + btoa("user1:pw1") + } + }) + .then(resp => resp.json()) + // 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 })); + } + + render() { + return ( +
+ {this.state.object === null ? null : ( + + )} +
+ ); + } +} + +export default ObjectView; -- cgit v1.1