0

I am sending a data along with $http.get request like below to node server.

$http.get("/deletebookData",{pathsrc : "a"}).success(function (result) {}); 

on node js i am not able to receive the {pathsrc : "a"} sent in get request.

app.get("/deletebookData", function (req, response) {
      console.log(req.body);
}); 

only empty json is printed in console

1 Answer 1

1

You are not sending the data. Check the $http.get documentation.

If you want to include params in your request use:

$http({
  url: '/deletebookData',
  method: 'GET'
  params: {pathsrc : "a"}
})
.then(function(){..});

Or:

$http.get('/deletebookData',{params: {pathsrc :'a'}}).then(function(){..});

Or build your url manualy:

$http.get("/deletebookData?pathsrc=a").then(function(){..})

(Also, please note that since angular 1.4 .success() is deprecated. Use .then() instead)

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

1 Comment

The question about how to send data to server in request body

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.