Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created July 1, 2017 08:49
Show Gist options
  • Select an option

  • Save solanoize/b084bc58e061b365064e6da3a38bff1e to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/b084bc58e061b365064e6da3a38bff1e to your computer and use it in GitHub Desktop.
var app = angular.module('app', []);
app.controller('LoginController', function($scope, $http, $templateCache) {
$scope.username = "";
$scope.password = "";
$scope.login = function() {
console.log($scope.username);
var auth = window.btoa($scope.username + ":" + $scope.password);
var headers = {"Authorization": "Basic " + auth};
$http({
url: "http://127.0.0.1:8000/api/v1/login/",
method: 'POST',
headers: headers,
cache: $templateCache,
data: {
username: $scope.username
}
}).then(function(response) {
console.log(response.data);
}, function(response) {
console.log("Yummm");
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment