File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,18 @@ import React from 'react';
2
2
import DisplayList from './DisplayList' ;
3
3
4
4
var rand = require ( 'random-key' ) ;
5
+ var api = require ( "../utils/api" ) ;
5
6
6
7
export default class App extends React . Component {
7
8
8
9
constructor ( ) {
9
10
super ( ) ;
10
- this . state = { title : '' , todos : [
11
- { title : 'eggs' , done : false , id : 1 } ,
12
- { title : 'banana' , done : false , id : 2 } ,
13
- { title : 'bread' , done : false , id : 3 }
14
- ] } ;
11
+ this . state = { title : '' , todos : [ ] } ;
12
+ var processDataCallback = function ( data ) {
13
+ this . setState ( { todos : data . todos } ) ;
14
+ } ;
15
+
16
+ api . getTasks ( processDataCallback . bind ( this ) ) ;
15
17
}
16
18
17
19
handleDone ( idToBeMarkedAsDone ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ var Constants = require("./constants");
2
2
var $ = require ( 'jquery' ) ;
3
3
4
4
var api = {
5
+ getTasks ( processDataCallback ) {
6
+ var url = Constants . BASE_URL + 'todos' ;
7
+ this . makeAjaxCall ( url , 'GET' , { } , processDataCallback )
8
+ } ,
9
+
5
10
makeAjaxCall ( url , type , params , processDataCallback ) {
6
11
$ . ajax ( {
7
12
type : type ,
You can’t perform that action at this time.
0 commit comments