Last active
April 27, 2017 18:02
-
-
Save Archakov06/1ae218e7180998d2a7ea7d081f6b786e to your computer and use it in GitHub Desktop.
My function
This file contains hidden or 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
$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