Skip to content

Commit 422b0b2

Browse files
committed
-#2 - added api.js
1 parent c68e8c2 commit 422b0b2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ep19-call-api-jquery/app/utils/api.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var Constants = require("./constants");
2+
var $ = require('jquery');
3+
4+
var api = {
5+
makeAjaxCall (url, type, params, processDataCallback) {
6+
$.ajax({
7+
type: type,
8+
url: url,
9+
data: {
10+
api_key: Constants.API_KEY,
11+
todo: params
12+
},
13+
dataType: 'json',
14+
success: function(data) {
15+
console.log(data);
16+
processDataCallback(data);
17+
},
18+
error: function() {
19+
console.log("An error has occurred");
20+
}
21+
});
22+
}
23+
};
24+
25+
module.exports = api;

ep19-call-api-jquery/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"webpack-merge": "^0.1.2"
2424
},
2525
"dependencies": {
26+
"jquery": "1.11.3",
2627
"random-key": "^0.3.2",
2728
"react": "^0.13.3"
2829
}

0 commit comments

Comments
 (0)