AngularJS passing data to $http.get request
An HTTP GET request can't contain data to be posted to the server. However, you can add a query string to the request.
angular.http provides an option for it called params
.
$http({ url: user.details_path, method: "GET", params: {user_id: user.id} });
See: http://docs.angularjs.org/api/ng.$http#get and https://docs.angularjs.org/api/ng/service/$http#usage (shows the params
param)
You can pass params directly to $http.get()
The following works fine
$http.get(user.details_path, { params: { user_id: user.id }});
Starting from AngularJS v1.4.8, you can useget(url, config)
as follows:
var data = { user_id:user.id};var config = { params: data, headers : {'Accept' : 'application/json'}};$http.get(user.details_path, config).then(function(response) { // process response here.. }, function(response) {});