1

I am trying to get parameters from get request in Node.js through Angular.JS but getting undefined in output

http://localhost:3000/admin/dashboard?id=582c5211c8a8e06c0849a238

My CRUD is

"dashboard":{
     schema:DashboardSchema,
     custom:[{
         type:"after",
         request: "get",
         controller: dashboardController.dashboard
     }]
}

My Node.js code is

dashboard: function(req,res){
     console.log("here");
     console.log(req.params);
     console.log(req.params.id);
     return res.status(200).send({"data":"123"});
});

The console window shows like this

GET /admin/dashboard?id=582c5211c8a8e06c0849a238 200 153.463 ms - 14 In decode data { id: '582c5211c8a8e06c0849a238' } here { id: undefined } undefined

Please help !

1 Answer 1

3

http://localhost:3000/admin/dashboard?id=582c5211c8a8e06c0849a238

Here as you are passing in query so try req.query.id

If you are passing the parameters as http://localhost:3000/admin/dashboard/582c5211c8a8e06c0849a238 then you can use req.params.id

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

1 Comment

Thanks a lot... It worked Answer would be accepted after 10 minutes according to stackoverflow

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.