Struggling to figure out how to get this functioning properly... I'm attempting to retrieve the CSRF from the API and use it as a constant in my AngularJS application. The code snippet I used is from @David Mosher, found here: https://gist.github.com/davemo/6141699. I kick off the app.js by doing this:
// Obtain and inject the CSRF token from the server
(function() {
var $injector = angular.injector(['ng']); $injector.invoke(function($http,$rootScope) {
$rootScope.$apply(function() {
$http.get("http://api.local/auth/csrf_token").then(function(response)
{
angular.module("app").constant("CSRF_TOKEN", response.data);
console.log(CSRF_TOKEN);
angular.bootstrap(document, ['app']);
});
});
});
})();
Upon checking, I receive a 200 status code along with the csrf_token. However, the CSRF_TOKEN seems to not be set within the app... the console.log(CSRF_TOKEN) results in a ReferenceError: CSRF_TOKEN is not defined....
Any insights into what I might be missing or doing incorrectly??
Thank you for your help! :-)