File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from 'react' ;
2- import axios from 'axios' ;
32import Header from './Header' ;
43import 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 }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ReactDOM from 'react-dom' ;
3+ import axios from 'axios' ;
34
45import 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+
You can’t perform that action at this time.
0 commit comments