Saturday 15 April 2017

Angular Controller Sending and Receiving Data from a Nodejs Server

Building on this solution here, I am working on being able to receive a response back from the node server.

Angular Controller

$scope.loginUser = function() {
      $scope.statusMsg = 'Sending data to server...';
      $http({
             url: 'http://##.##.##.##/login', 
             method: 'POST',
             data: user,
             headers: {'Content-Type': 'application/json'}
      })
}

Nodejs Server

app.post('/login', function(req, res) {
   console.log('Processing request...');
   res.sendFile('/success.html');
});

How can this example be extended to be able to receive a response back from the server?



via JMM

No comments:

Post a Comment