Wednesday, 7 June 2017

empty req.body in post request (express)

I wondering why i have an empty req.body, because i using body parser and have headers in request, please help me, maybe i have some mistake or forget something to add, anyway i looked for information about my problem and all that a i have found is about body parser and headers

// create application/json parser
let jsonParser = bodyParser.json()

// create application/x-www-form-urlencoded parser
let urlencodedParser = bodyParser.urlencoded({ extended: false })

app.use(jsonParser);
app.use(urlencoded_body_parser);

router.post('/insert', (req, res, next) => {
  let item = req.body;
  console.log(item);
  // res.redirect('/');
});



via Денис Могила

No comments:

Post a Comment