I want to get post query values to create a new row in the database. But in req.query It don't works. I also tried with body-parser but it also didn't worked. The code
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './static/image/')
},
filename: (req, file, cb) => {
const { originalname } = file;
cb(null, originalname)
filename = originalname;
}
})
const upload = multer({ storage: storage })
app.post('/admin/song/create', upload.single('file'), async(req, res) => {
console.log(req.query)
res.redirect('/admin')
})
And I also did set the middleware for body-parser but It also don't work. But It does work with GET requests. Why It doesn't work with the POST request. If Anyone knows Please respond. It will be helpful.
Aucun commentaire:
Enregistrer un commentaire