【问题标题】:How to receive text on POST with NodeJS如何使用 NodeJS 在 POST 上接收文本
【发布时间】:2020-04-02 12:47:10
【问题描述】:

我需要在我的 POST 路由上接收简单的文本:

'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;

它返回{}

我发现有些人使用body parse,我尝试这样使用:

const bodyParser = require('body-parser')

router.use(bodyParser.json());

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

没有用。我不是 NodeJS 专业人士。我怎样才能让它工作?

【问题讨论】:

    标签: node.js express


    【解决方案1】:

    也许bodyParser.text() 就是你要找的。​​p>

    Expressjs raw body

    【讨论】:

      猜你喜欢
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 2021-06-12
      • 2020-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多