I got an application where a specific function makes a post request and receives in the callback a JsonWebToken. I have to redirect to another endpoint which will render a new page, passing the token in the header.
Using the following code, I know it gets on the desired endpoint, because "Here I am" is printed, but the page is not rendered. What am I doing wrong?
Controller:
var app = angular.module('loginApp'['ui.utils.masks','ui.bootstrap'])
app.controller('LoginCtrl', function($location,$scope,$http){
function login(){
$http.post('/authentication',$scope.user).then(function
successCallback(response) {
$http({
url : '/home',
method : 'GET',
headers : {
Authorization: "JWT " + response.data.token
}
})
}
}
Routes file:
var express = require('express')
var router = express.Router()
router.get('/home', function(req, res) {
console.log("Passing here")
res.render('home.pug')
}
module.exports = router