Answer the question
In order to leave comments, you need to log in
How to get formData in nodejs?
Hello.
The site sends a post with a formData object to the nodejs server. I look at the result in the console - an empty object. The problem is probably in the wrong parser parameters. I will give the code below, please advise.
const express = require ('express');
const bodyParser = require('body-parser');
const app = express();
const cors = require('cors');
const PORT = 3000;
const parser = bodyParser.urlencoded({extended:false});
app.use(cors())
app.post('/', parser, (req,res)=>{
console.log(req.body)
})
app.listen(PORT, (err)=>{
console.log(`Server starting on ${PORT} port`)
})
Answer the question
In order to leave comments, you need to log in
Nice and simple package for solving the formidable problem https://www.npmjs.com/package/formidable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question