BuildForSDGCohort2 / BuildForSDGCohort2/TEAM-050-Backend
Needs Attention please!
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
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 https://github.com/BuildForSDGCohort2/TEAM-050-Backend/issues/13#issuecomment-703031499_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the controller and route handling GET /api/v1/citizen/profile/:id, then inspect how req.user is populated and how Citizens.findOne currently retrieves the citizen. Done means the profile endpoint no longer requires a separate id, returns the authenticated citizen's details, and excludes the password field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100