0

I notice my get-data isn't passed through in my GET request. I've stripped it down to:

$http({ url: "http://www.myurl.com/somefolder/demo.php", method: "GET", data: { info: "lala"}, timeout: 5000 }) .then(function (res) { var data = res.data; console.log((data)); },function (error) { alert("Something went wrong"); }) 

demo.php only contains:

<?php var_dump($_GET) ?> 

It does work when I visit the URL with my browser, but via the http-get, everything seems fine but the data is never past. console.log(data) always returns array(0) {} as if I didn't send any data.

Don't know if this is relevant, but I'm using this in an Angular based Ionic-app, and I'm testing it in my browser. It's puzzling me for hours now...

1
  • I ended up putting my params in the url http://www.myurl.com/somefolder/demo.php?info=lala Commented Jan 5, 2016 at 14:21

1 Answer 1

3

In the configuration object, data represents the body of the request (Used by a POST request for example). It seems that you want to add parameters to the URL. You should use params key instead.

$http({ url: "http://www.myurl.com/somefolder/demo.php", method: "GET", params: { info: "lala"}, timeout: 5000 }) 

More details here: https://docs.angularjs.org/api/ng/service/$http#usage

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.