Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. router.post('/useraccount',passport.authenticate('jwt',{session:false}),multer.single('avatar'),(req,res) => {
  2. Account.findOne({user:req.user.id})
  3. .then( async account => {
  4. if(account) {
  5. return res.json('account has been registerd')
  6. }
  7.  
  8. let result = await cloudinary.v2.uploader.upload(req.file.path);
  9. const newAccount = new Account({
  10. user:req.user.id,
  11. userName:req.body.userName,
  12. email:req.body.email,
  13. title:req.body.title,
  14. avatar:result.secure_url,
  15. bio:req.body.bio,
  16. })
  17. newAccount.save()
  18. .then(newAccount => {
  19. res.json(newAccount)
  20. })
  21. .catch(err => {
  22. res.status(404).json(err)
  23. })
  24.  
  25. }).catch(err => {
  26. res.json(err)
  27. })
  28. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement