Please I am try to make post and get request from postman that will save the path of the image to mongodb not binary. I successfully posted the data to mongodb that includes form-data(text and file) but the file is a buffer. I want it to be a binary data, so that when I want to get it back I won't get a binary data. text is posting successfully, and am getting the required text back but image is sending binary and am getting binary back which is very bad idea.
Please I need help.
//POST Request
app.post('/request', upload.single('images'), async function(req, res){
const requestBody = {
name: req.body.name,
description: req.body.description,
images: req.file.buffer
}
const request = new Request(requestBody)
try{
await request.save()
res.status(201).send()
}catch(e){
res.status(400).send(e)
}
})
//GET request
app.get('/request', async function(req, res){
try{
const requests = await Request.find({})
// console.log(requests)
res.send()
}catch(e){
res.status(500).send()
}
})