Answer the question
In order to leave comments, you need to log in
How to get image from mongodb?
// Код который загружает файл в mongoDB
const upload = multer({dest: './uploads/'});
router.post('/setting', upload.single('file'), async (req, res) => {
const {id} = await req.body
const {name, surname, birthDay, country, city} = await req.body
const host = req.host;
const filePath = req.file.path
await User.findOneAndUpdate({_id: id}, {
name,
surname,
birthDay,
country,
city,
profilePhoto: filePath
})
res.json({filePath, file: req.file})
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question