Skip to content

Instantly share code, notes, and snippets.

@DevEarley
Created June 18, 2017 02:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevEarley/43e6f7b5c6c2c15de0a721d214321d6b to your computer and use it in GitHub Desktop.
Save DevEarley/43e6f7b5c6c2c15de0a721d214321d6b to your computer and use it in GitHub Desktop.
Your Everyday service.
'use strict';
angular.module('myApp').service('UserService', ['$http', '$window', function ($http, $window) {
return {
getUsers: function () {
return $http({
method: 'GET',
url: $http.defaults.apiUrl + '/users',
headers: { 'Authorization': $window.sessionStorage.token }
}).then(function (data) { return data.data; });
},
getUser: function (_userName) {
return $http({
method: 'GET',
url: $http.defaults.apiUrl + '/userByName/' + _userName,
headers: { 'Authorization': $window.sessionStorage.token }
}).then(function (data) { return data.data; });
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment