I want to use body param instead of query string in nodejs. So far i have prepared this code.
Router.js
router.get("/getUserDetailsbyId/:id", getUserDetailsbyId);
Controller.js
getUserDetailsbyId: (req, res) => {
        console.log(req.body);
      const id = req.params.id;
      getUserDetails(id, (err, results) => {
        if (err) {
          console.log(err);
          return;
        }
        if (!results) {
          return res.json({
            success: 0,
            message: "Record not Found"
          });
        }
        results.password = undefined;
        return res.json({
          success: 1,
          data: results
        });
      });
    },
I am running this url in Postman.
http://localhost:3000/getUserDetailsbyId
This is the body in GET request. { "id":1 }
Output
<pre>Cannot GET /getUserDetailsbyId</pre>
No idea what i am doing wrong.I tried both method to check data is coming or not. console.log(req.body); const id = req.params.id;
Edit
I have made some changes in the router.js
router.get('/getUserDetailsbyId', (req, res) => {
    const { id } = req.body;
    getUserDetailsbyId(res.id);
    }),
Now i need to understand how to get this data in controller or sql query.
 
    