0

I need to receive simple text on my POST route:

'use strict';

const express = require('express');
const functions = require('../../utils/functions');

let router = express.Router();

router.post('/ses', function(req, res) {

    res.send(req.body)

});

module.exports = router;

It returns {}

I found some people using body parse and I tried to use like this:

const bodyParser = require('body-parser')

router.use(bodyParser.json());

// and tried it too. Not together, of course
router.use(bodyParser.urlencoded({ extended: false }))

It didn't work. I'm not a NodeJS pro. How can I get it working?

dm707
  • 352
  • 2
  • 15

1 Answers1

1

Perhaps bodyParser.text() is what you are looking for.

See Expressjs raw body

sunknudsen
  • 6,356
  • 3
  • 39
  • 76