On Postman, if there is a POST request and it is added in Body > raw a JSON file, one can access inside the code with req.params.thatProperty.
For example, we have this JSON in Body:
{
"email": "email@test.com",
"password": "secret"
}
in code:
app.post('/myUrl', (req, res) => {
//here we can access the email by req.params.email
}
My question is, if the have in Body > form-data like in the following screenshot, how can we access the email on the request? There it's no req.params
in this case.
But because I'm uploading a file and I'm using Multer, I do have access to
req.file
. The problem is that in req.file is only information related to the image, nothing about the email.
the function starts like this:
app.post('/upload', upload.single('value'), (req, res, next) => {
//how can I have access to the email from the request here?
}
Your form data should be in req.body