user3061943
user3061943

Reputation: 99

Access GET parameter

I want to send my server.js (in an AngularJS controller) an set the id parameter like this:

 $http
    .get('/getCst', {
        params: {               
            id: customerID
        }
     })
     .success(function (data,status) {
          $scope.customer = data
     });

But i'm not sure if this is the correct way and what to write in the Node.js server.js:

app.get('/getCst', function (req, res) {

        console.log(//how do i get the id sent by the client?);     
});

Upvotes: 2

Views: 587

Answers (3)

dev verma
dev verma

Reputation: 777

app.get('/getCst', function (req, res) {

    var id = req.query.id;   

});

Upvotes: 0

MaximeF
MaximeF

Reputation: 5373

It's my solution

app.get('/getCst/:id', function (req, res, next) {

        var id = req.params.id;    
});

Upvotes: 3

squiroid
squiroid

Reputation: 14027

Try this:

app.get('/getCst:id', function (req, res) {

        console.log(req.param('id'));     
});

Upvotes: 0

Related Questions