-
Notifications
You must be signed in to change notification settings - Fork 0
/
githubService.js
36 lines (29 loc) · 914 Bytes
/
githubService.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function() {
var github = function($http, $log) {
var onUserComplete = function(response) {
return response.data;
}
var onReposComplete = function(response) {
return response;
}
var getUser = function(username) {
var apiUrl = "https://api.github.com/users/" + username;
$log.info("Calling Api - " + apiUrl);
return $http.get(apiUrl)
.then(onUserComplete);
};
var getRepos = function(username) {
var apiUrl = "https://api.github.com/users/" + username + "/repos";
$log.info("Calling Api - " + apiUrl);
return $http.get(apiUrl)
.then(onReposComplete);
}
return {
getUser: getUser,
getRepos: getRepos
};
};
// Add the service to the app's main module
var module = angular.module("githubViewer");
module.factory("github", ["$http", "$log", github]);
}());