Turqus
Turqus

Reputation: 117

Sending variable by http get

I have problem with sending variable by http.get, can someone correct me?

$http.get("/product/products", { 'quantity': 5 }).then(function (resp) {
    $scope.products = resp.data;
})

Thanks much

Upvotes: 1

Views: 330

Answers (2)

Sachila Ranawaka
Sachila Ranawaka

Reputation: 41397

cant send a request body for get request. you can either change it to a POST request or send the variable as params

$http.get("/product/products", { params: { 'quantity': 5 }}).then(function (resp) {
    $scope.products = resp.data;
})

Upvotes: 0

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

You should be sending it as params property of config object.

$http.get("/product/products", { params: { 'quantity': 5 }})

Upvotes: 3

Related Questions