Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.post('/useraccount',passport.authenticate('jwt',{session:false}),multer.single('avatar'),(req,res) => {
- Account.findOne({user:req.user.id})
- .then( async account => {
- if(account) {
- return res.json('account has been registerd')
- }
- let result = await cloudinary.v2.uploader.upload(req.file.path);
- const newAccount = new Account({
- user:req.user.id,
- userName:req.body.userName,
- email:req.body.email,
- title:req.body.title,
- avatar:result.secure_url,
- bio:req.body.bio,
- })
- newAccount.save()
- .then(newAccount => {
- res.json(newAccount)
- })
- .catch(err => {
- res.status(404).json(err)
- })
- }).catch(err => {
- res.json(err)
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement