npm install body-parser
const express = require('express');
const { v4: uuidv4 } = require('uuid');
const app = express();
const port = 3000;
const bodyParser = require('body-parser');
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.use(bodyParser.json())
app.post('/api/text',(req, res) => {
console.log("---", req.body);
res.send("text");
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
req.on('end', () => {
console.log("---", body);
});
const express = require('express');
const { v4: uuidv4 } = require('uuid');
const app = express();
const port = 3000;
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.post('/api/text',(req, res) => {
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', () => {
console.log("---", body);
});
res.send("text");
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})