-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
82 lines (65 loc) · 1.62 KB
/
App.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { Component } from 'react';
import styles from './App.css';
import {Jumbotron, PageHeader, Table, Row, Col, Navbar, Nav, NavItem} from 'react-bootstrap';
import Navs from './Navs.js';
import Jumbo from './Jumbo.js';
import Section1 from './Section1.js';
import neoData from './sample-neo.js';
class App extends Component {
constructor(props){
super(props)
this.state = {
iss_url: "http://api.open-notify.org/iss-now.json",
iss_data: neoData
}
}
componentWillMount() {
var self = this;
fetch(`${this.state.iss_url}`).then(function(response) {
return response.json();
}).then(function(response) {
self.setState({iss_data: response})
});
}
componentDidMount() {
var self = this;
setInterval(function() {
fetch(self.state.iss_url).then(function(response) {
return response.json();
}).then(function(response) {
self.setState({iss_data: response})
});
}, 5000);
}
render() {
const c = this.state.iss_data.iss_position
return (
<div>
<div>
<Navs />
</div>
<div>
<Jumbo />
</div>
<div>
<Section1 />
</div>
<div className="container">
<Row>
<Col xs={6}>
<h2 className="center-block"> Space Station Longitude </h2>
<h3 className="center-block">{c.longitude}</h3>
</Col>
<Col xs={6}>
<h2 className="center-block"> Space Station Latitude </h2>
<h3 className="center-block">{c.latitude}</h3>
</Col>
</Row>
</div>
<div id="meow">
</div>
</div>
);
}
}
export default App;