Created
October 20, 2015 14:50
-
-
Save andyczerwonka/1596718fd7e61036045f to your computer and use it in GitHub Desktop.
This code works using `ionic serve` but not `ionic emulate android`
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
var login = function(credentials) { | |
var deferred = $q.defer(); | |
$http.post(loginEndpoint, credentials).then(function(response) { | |
console.log("Login successful"); | |
localStorage.authToken = response.data; | |
$http.defaults.headers.common.Authorization = 'auth-token ' + localStorage.authToken; | |
$http.get(whoamiEndpoint).then(function(response) { | |
self.user = response.data; | |
deferred.resolve(response.data); | |
}); | |
}, function(error) { | |
console.log("Login failed"); | |
var errorString = JSON.stringify(error, null, 4); | |
console.log(errorString); | |
deferred.reject(error.data); | |
}); | |
return deferred.promise; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get a failure under
ionic emulate android
, but it works usingionic serve
just fine.I do see a warning when running
emulate
:26 604225 warn No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.