I am trying to read formData that I send to my server. First I append something to a formData
object. It looks like this:
const formData = new FormData();
formData.append('email', this.email);
My post request looks like this:
axios.post('/api/auth/register', formData, {
headers: {
'accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.8',
'Content-Type': `multipart/form-data; boundary=${formData._boundary}`,
}
})
My backend route:
router.post('/register', (req, res) => {
//this does log the email 'key', but the value is empty
console.log('email: ', req.body)
res.status(200).end()
})
How can I 'access' the email value on the server?
I've tried parsing it first with
email = JSON.parse(req.body.email);
But whatever I do, I cannot seem to get the value that I send...
I do have bodyParser installed. This is in my app.js
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))