Search Posts

Category: post

Nodejs callback response not working as expected

I’m trying to authenticate a user based on values entered in a given form. However, after using res.send(), the function at AngularJS controller is not able to correctly redirect user even if the password and username are correct. Am I handling the callbacks correctly? Controller <script> var app = angular.module(‘myApp’, []); app.controller(“loginController”, function($scope,$http) { $scope.sub = function() { var config = { headers : { ‘Content-Type’: ‘application/x-www-form- urlencoded;charset=utf-8;’ } } $http.post(‘/login’, { data:{ username: $scope.username, […]

Nodejs Express redirecting does not work

I’m currently trying to redirect a user to a success screen after he click the login button. Everything seems to be working fine but the page does not change. Tried searching online but none of the solution helped. Update It seems that the root cause is because of ‘/’ in routes. Changed it to ‘/home’ and it works now Solved Below is my html, server and route codes index.html <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”> […]