You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1008 B
53 lines
1008 B
7 years ago
|
import React from 'react';
|
||
6 years ago
|
|
||
6 years ago
|
const SERVER_URL = 'http://localhost:3000/'
|
||
7 years ago
|
|
||
|
export default class Site extends React.Component {
|
||
7 years ago
|
|
||
6 years ago
|
state = {
|
||
|
classes: [],
|
||
|
psboard: [],
|
||
|
componentMounted: false
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
callAPI = (targetUrl) => {
|
||
|
let url = SERVER_URL + 'api/data/'+ targetUrl
|
||
|
let data = ""
|
||
|
console.log(url);
|
||
|
|
||
|
fetch(url)
|
||
6 years ago
|
.then(response => response.json())
|
||
6 years ago
|
.then(body =>
|
||
|
this.setState({
|
||
|
[targetUrl]: body
|
||
|
}));
|
||
7 years ago
|
}
|
||
|
|
||
6 years ago
|
componentDidMount() {
|
||
|
this.callAPI('classes')
|
||
|
this.callAPI('psboard')
|
||
6 years ago
|
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
6 years ago
|
render() {
|
||
6 years ago
|
console.log(this.state)
|
||
7 years ago
|
return (
|
||
7 years ago
|
<div className="mainContainer">
|
||
6 years ago
|
<div className="left">
|
||
|
<div className="heading">Upcoming Classes</div>
|
||
6 years ago
|
|
||
|
{this.state.psboard.map((item, i) =>
|
||
6 years ago
|
<div className='course-list'>
|
||
|
<div className='subject'>{item.subject}</div>
|
||
|
<div className='date'>{item.date}</div>
|
||
|
</div>)}
|
||
|
|
||
6 years ago
|
</div>
|
||
6 years ago
|
<div className="right">
|
||
|
<div className="heading">Posts</div>
|
||
|
</div>
|
||
7 years ago
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|