Also, when we hit 'GET /api/v1/citizen/profile/:id'
the id parameter in the req will course a lot of problems, its suppose to be a the citizen._id right?
but i can't get the citizen details until this code runs const citizen = await Citizens.findOne({ _id: req.params.id });
And that code only runs on a GET request to /api/v1/citizen/profile/:id which requires a param of the citizen id,whc i dont have yet
so i suggest you change the controller url from /api/v1/citizen/profile/:id to /api/v1/citizen/profile
And
const citizen = await Citizens.findOne({ _id: req.params.id });
to something like :
const citizen= await Citizens.findById(req.user, '-password'); res.json({ citizen});
Originally posted by @sleekLancelot in #13 (comment)
Also, when we hit 'GET /api/v1/citizen/profile/:id'
the id parameter in the req will course a lot of problems, its suppose to be a the citizen._id right?
but i can't get the citizen details until this code runs
const citizen = await Citizens.findOne({ _id: req.params.id });And that code only runs on a GET request to
/api/v1/citizen/profile/:idwhich requires a param of the citizen id,whc i dont have yetso i suggest you change the controller url from
/api/v1/citizen/profile/:idto/api/v1/citizen/profileAnd
const citizen = await Citizens.findOne({ _id: req.params.id });to something like :
const citizen= await Citizens.findById(req.user, '-password'); res.json({ citizen});Originally posted by @sleekLancelot in #13 (comment)