blob: 4a04c93245dc3383051c6992ab29d1057fbe34ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 (
<div id="object-view">
{this.state.object === null ? null : (
<ObjectComponent {...this.state.object} />
)}
</div>
);
}
}
export default ObjectView;
|