I have two get request but in postman If I hit the second get request with the correct url then always run the first AND give response of the 1st request. optimize the question
router.get(
"/:id",
[auth],
usersController.getUser
);
router.get(
"/allUser",
[auth],
usersController.getAllUser
);
the userController file & relevant methods
exports.getUser = async (req, res) => {
const id = req.params.id;
try {
let result = await userService.getUserAccount(id);
if (result) {
const resultWithoutPassword = {...result};
delete resultWithoutPassword.password;
return res.status(HttpCodes.OK).send(resultWithoutPassword);
}
//console.error("error: Not Found.");
return res.status(HttpCodes.NOT_FOUND).send(AppMessages.USER_NOT_FOUND);
} catch (error) {
return res.status(HttpCodes.INTERNAL_SERVER_ERROR).json(
{
Error: AppMessages.INTERNAL_SERVER_ERROR,
Message: "Id Should be an Integer."
});
}
}
try{
let result = await userService.getAllUserAccounts();
return res.status(httpCodes.OK).json(result);
}
catch(err){
return
res.status(httpCodes.INTERNAL_SERVER_ERROR).json({ERROR:
AppMessages.INTERNAL_SERVER_ERROR});
}
}