0

I am using "$http.get" for send request. My API response in browser, it returns what i want. But in Ionic App, it return HTML body tag text.

My Code is:

    var params = {
        email: '[email protected]',
        password: '123'
    }

    $http.get("https://www.nepalivivah.com/API/index.php/accessapi/loginapi", { params: params }).then(function (data) {
        alert(JSON.stringify(data));
    }).error(function (data) {
        alert(JSON.stringify(data));
    });

This is my AngularCode. When i run it in postman, it return valid response. But in Ionic App not Working.

1
  • "Not working" is too broad of a description. How is it not working? What are the errors? Is the data different that what you expected? Commented Sep 13, 2016 at 18:54

1 Answer 1

1

If you want the $http.get, this should work.

var params = {
    email: '[email protected]',
    password: '123'
}

$http.get("https://www.nepalivivah.com/API/index.php/accessapi/loginapi").then(function (data) {
    alert(JSON.stringify(data));
}).error(function (err) {
    alert(JSON.stringify(err));
});

However, in this case, what you are trying to do is to login into something. A get request will not work with this. You need to use $http.post at least in this case.

Sign up to request clarification or add additional context in comments.

2 Comments

My API in GET method. I also try it with POST method. But it is not working. Same response received in POST method.
Maybe you need another parameter(s) for the $http.post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.