Skip to content

Instantly share code, notes, and snippets.

@Archakov06
Last active April 27, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archakov06/1ae218e7180998d2a7ea7d081f6b786e to your computer and use it in GitHub Desktop.
Save Archakov06/1ae218e7180998d2a7ea7d081f6b786e to your computer and use it in GitHub Desktop.
My function
$scope.getProblematics = function(callback) {
var url = $scope.makeAPI('/problematics');
$http.get(url, {
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"auth_token": $.cookie('auth_token')
}
})
.success(function(data, status, headers, config) {
switch (status) {
case 200:
$scope.options.problematics = data;
break;
}
if (callback) $timeout(function() { callback() });
})
.error(function(data, status, headers, config) {
switch (data.status) {
case 401:
$.cookie('auth_token', null, { path: '/' });
$scope.redirect('/interface/auth/login/index.html');
break;
}
if (callback) $timeout(function() { callback() });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment