I'm having an issue where my req.body is always undefined when I do a POST. I'm using NodeJS, Express and BodyParser. Everything else I can find online says I need the include .json(), as below on the 1st line, but this didn't sort the issue. I've also tried with {extended: true}
which also didn't help.
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname, 'public')));
app.use(cookieParser());
app.use(
session({
secret: 'my secret',
resave: false,
saveUninitialized: false,
store: site
})
);
If I run a line of code like req.body.text
I'll just get undefined
as the result. Does anyone know what my mistake might be?