📜  如何使用 express nodejs 解析 POST 请求 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:50.593000             🧑  作者: Mango

代码示例1
const express = require('express');
const bodyParser = require('body-parser');

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/post-test', (req, res) => {
    console.log('Got body:', req.body);
    res.sendStatus(200);
});

app.listen(8080, () => console.log(`Started server at http://localhost:8080!`));