Skip to content Skip to sidebar Skip to footer

Login Using Angular Js And $http Request Not Working

I want to login using $http and GET of REST web services. What I am doing is: Taking data on the basis of username and password using $http.get Storing the result: $scope.getResul

Solution 1:

Replace the raw window.location method with the AngularJS $location service. Calling window.location from inside a $q service fulfillment handler will generally result in an AngularJS internal error.

$http.get("http://localhost:17681/api/userRegisters"+user+pass)
  .then(functiononFulfilled(response) {

    $scope.getResult = response.data;

    var result = $scope.getResult;
    var username = result.userName;
    var password = result.password;

    if (username == user && password == pass) {
      //Use this$location.path("/next.html");
      //Not this//window.location="/next.html";
    }
}).catch ( functiononRejected(response) {
    console.log(response.status);
});

For more information, see AngularJS $location Service API Reference.

Deprecation Notice

The $http legacy promise methods .success and .error have been deprecated. Use the standard .then method instead.


Debugging the Response

Its gives record via response.data but doesnt give column records. what should be done in order to fetch data ?

What is the specification for the server side API?

What is the server side code that generates the response data?

These are things readers will need to know in order to help you. Otherwise any answer is just a guess.

Industry best practice is to avoid sending passwords as a parameter of a URL as that has security issues.

Two resources recommended by the AngularJS team:


Additional Resources

Post a Comment for "Login Using Angular Js And $http Request Not Working"