Ankit21ks
Ankit21ks

Reputation: 484

AngularJS $http - how to add query params to POST request

I am new to AngularJS. I am trying to POST data to call.php page from AngularJS page. My code for that is:

var request=$http({
                    url: "call.php",
                    method: "POST",
                    data: { uid: uname,upass: upass }
                });

But on call.php page it says undefined index:uid.I want this uid and pass on call.php page and according to that I will search database row. Please help me, Where I am wrong? Thanx in advance.

Upvotes: 2

Views: 118

Answers (1)

tomastrajan
tomastrajan

Reputation: 1726

As described in official documentation use $http.post('/target/url', optionalDataInRequestBody, params: { param1: 'value1', param:2: 'value2'}), post sends data as request body but it looks like you want to acces them as query params.

Upvotes: 1

Related Questions