Skip to content

Instantly share code, notes, and snippets.

@andyczerwonka
Created October 20, 2015 14:50
Show Gist options
  • Save andyczerwonka/1596718fd7e61036045f to your computer and use it in GitHub Desktop.
Save andyczerwonka/1596718fd7e61036045f to your computer and use it in GitHub Desktop.
This code works using `ionic serve` but not `ionic emulate android`
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;
};
@andyczerwonka
Copy link
Author

I get a failure under ionic emulate android, but it works using ionic 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment