Login Using Angular Js And $http Request Not Working
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
$httplegacy promise methods.successand.errorhave been deprecated. Use the standard.thenmethod 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:
Post a Comment for "Login Using Angular Js And $http Request Not Working"