-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement edit profile feature #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| require('dotenv').config(); | ||
| const User = require('./../models/user') | ||
| const {ERROR, SUCCESS} = require('.././assests/constants') | ||
|
|
||
|
|
||
|
|
||
| const editProfile = async (req, res) => { | ||
| try { | ||
| const id = req.params.id; | ||
| const userData = await User.findById({userId: id}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. user models does not have this find by id method you are trying to call here. Did you test this to see that it works |
||
| if (userData) { | ||
| res.status(SUCCESS).json({ | ||
| message:'userData found successfully', | ||
| data:userData | ||
| }) | ||
| }else { | ||
| res.status(ERROR).json({ | ||
| message: 'Wrong data found' | ||
| }) | ||
| } | ||
|
|
||
| }catch (err) { | ||
| res.status(ERROR).json({ | ||
| message: err.message | ||
| }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inside catch, all you need to do is next(err)....pass error into next so that the universal error handler will take care of it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inside catch, all you need to do is next(err)....pass error into next function so that the universal error handler will take care of it |
||
| } | ||
| } | ||
| module.exports = { | ||
| editProfile | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const express = require('express'); | ||
| const router = express.Router() | ||
| const {editProfileControllers} = require('../controllers/editProfileControllers') | ||
|
|
||
|
|
||
| router.post('/edit', editProfileControllers.editProfile) | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| module.exports = router |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(req, res, next) are the parameters for controllers