Angular JS POST Submission Failure

338
April 03, 2017, at 12:57 PM

I'm new to angular JS. I've followed an online tutorial and created a simple login form on the frontend, and linked it to the backend. Or at least I've tried. The backend is a nodejs/express server, which has a route for handling the login attempts from the frontend. It will be checking to see if the username and password used on the form are from an existing user account, or not.

The problem is that for some reason, the http POST call from the angular controller, always results in a ERR_CONNECTION_TIMED_OUT response in the browser console.

The thing is, though if I interface with the api endpoint using curl, it works just fine and the server does exactly what it's supposed to do. Just for some reason the angular frontend form cannot connect to the backend. Here's the angular controller code:

app.controller('loginCtrl, function($scope, $location, $http){
  $scope.login = function(){
    var parameter = JSON.stringify({ username: $scope.username, password: $scope.password });
    $http({
      url: 'https://localhost:8443/api/login'
      method: 'POST',
      data: parameter
    }).then(function(response){
      console.log('success: ' + JSON.stringify(response));
    },
    function(response){
      console.log('failed: ' + JSON.stringify(response));
    });
  }
});

The nodejs backend server is serving content over HTTPS. This controller function (login) is being hit, and the POST is being made, but it simply times out. And again, manually interfacing with these api endpoints works as expected when using curl or wget.

Any insight into the issue or what I'm doing wrong?

Rent Charter Buses Company
READ ALSO
Is there any way to simply store a string or other variable permanently without the use of a DB in node?

Is there any way to simply store a string or other variable permanently without the use of a DB in node?

Is there any way to store a variable in nodeJS kind of like localStorage but for the server? For example store a JSON object as a string for a small amount of data?

287
Allowing users to upload content to s3

Allowing users to upload content to s3

I have an S3 bucket named BUCKET on region BUCKET_REGIONI'm trying to allow users of my web and mobile apps to upload image files to these bucket, provided that they meet certain restrictions based on Content-Type and Content-Length (namely, I want to only allow jpegs less than 3mbs to be uploaded)

312
node deprecation warning: Calling an asynchronous function without callback is deprecated

node deprecation warning: Calling an asynchronous function without callback is deprecated

I have a problem trying to run my project on localhost:8080 with reloadSo when I try and start my project on localhost it gives me this error:

623
How to save variable using await function and use callback when error occurs?

How to save variable using await function and use callback when error occurs?

well I'm immigrating my code to ES7, syntaxes like arrow function and async/awaitThe problem is I don't get how to use call back when If I try to save variable and callback when error occurs at the same time using async/await

345