Created
October 20, 2017 12:09
-
-
Save kutsaniuk/9bd0731314bb7207ba7453336d8fb375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular | |
.module('main') | |
.service('UserService', function ($http, | |
$cookieStore, | |
$q, | |
$rootScope, | |
URL, BUCKET_SLUG, READ_KEY, WRITE_KEY) { | |
$http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; | |
this.getCurrentUser = function (ignoreLoadingBar) { | |
return $http.get(URL + BUCKET_SLUG + '/object/' + $rootScope.globals.currentUser.slug, { | |
ignoreLoadingBar: ignoreLoadingBar, | |
params: { | |
read_key: READ_KEY | |
} | |
}); | |
}; | |
this.getUser = function (slug, ignoreLoadingBar) { | |
return $http.get(URL + BUCKET_SLUG + '/object/' + slug, { | |
ignoreLoadingBar: ignoreLoadingBar, | |
params: { | |
read_key: READ_KEY | |
} | |
}); | |
}; | |
this.updateUser = function (user) { | |
user.write_key = WRITE_KEY; | |
return $http.put(URL + BUCKET_SLUG + '/edit-object', user, { | |
ignoreLoadingBar: false | |
}); | |
}; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment