Skip to content

Commit 77b976a

Browse files
committed
First solution to the checksum problem
1 parent f0d66a1 commit 77b976a

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/components/App.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import axios from 'axios';
32
import Header from './Header';
43
import ContestPreview from './ContestPreview';
54

@@ -9,17 +8,7 @@ class App extends React.Component {
98
contests: this.props.initialContests
109
};
1110
componentDidMount() {
12-
// Make Ajax call and load data response onto the state
13-
axios.get('/api/contests')
14-
.then(response => {
15-
// console.log(response.data.contests);
16-
this.setState({
17-
contests: response.data.contests
18-
});
19-
})
20-
.catch((error) => {
21-
console.log(error);
22-
});
11+
2312
}
2413
componentWillUnmount () {
2514
}

src/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import axios from 'axios';
34

45
import App from './components/App';
56

6-
ReactDOM.render(
7-
<App initialContests={[]} />,
8-
document.getElementById('root')
9-
);
7+
axios.get('/api/contests')
8+
.then(resp => {
9+
ReactDOM.render(
10+
<App initialContests={resp.data.contests} />,
11+
document.getElementById('root')
12+
);
13+
})
14+
.catch(console.error);
15+
16+

0 commit comments

Comments
 (0)