Reputation: 99
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
Reputation: 777
app.get('/getCst', function (req, res) {
var id = req.query.id;
});
Upvotes: 0
Reputation: 5373
It's my solution
app.get('/getCst/:id', function (req, res, next) {
var id = req.params.id;
});
Upvotes: 3
Reputation: 14027
Try this:
app.get('/getCst:id', function (req, res) {
console.log(req.param('id'));
});
Upvotes: 0