I have a function which does a http POST request. The code is specified below. This works fine.
$http({ url: user.update_path, method: "POST", data: {user_id: user.id, draft: true} });
I have another function for http GET and I want to send data to that request. But I don't have that option in get.
$http({ url: user.details_path, method: "GET", data: {user_id: user.id} });
The syntax for http.get
is
get(url, config)
get request Method Syntax: $http. get(url, { params: { params1: values1, params2:values2, params3:values3...... } });
To use this function you just need to create two NameValueCollections holding your parameters and request headers. Show activity on this post. You can also pass value directly via URL. If you want to call method public static void calling(string name){....}
response : interceptors get called with http response object. The function is free to modify the response object or create a new one. The function needs to return the response object directly, or as a promise containing the response or a new response object.
In angularjs get ($http. get()) service or method is used to get data from remote HTTP servers. In angularjs get is a one of the shortcut method in $http service. In other ways, we can say that $http. get service or method in $http service is used to get data from the given URI.
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 } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With