i having some issues, Cannot set headers after they are sent to the client. This is my back-end side error afterpost request.It looks like problem with headers
this my code
app.post('/upload', function (req, res) { //post data into databases
var data = { PhotoName: 'http://localhost:8000/public/'+req.body.filename+'.jpg'};
var sql = 'insert into photo set ?';
db.query(sql, data, (err, result) => {
if (err) throw err;
console.log(result);
res.send({
type: 'POST',
PhotoName:'http://localhost:8000/public/'+req.body.filename + '.jpg'
});
});
let imageFile = req.files.file;
imageFile.mv(`${__dirname}/public/${req.body.filename}.jpg`, function (err) {
if (err) {
return res.status(500).send(err);
}
res.json({ file: `public/${req.body.filename}.jpg` });
});
});
thank you very much