receive data post express code example
Example 1: express js post request body
const express = require('express')
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.post('/profile', function (req, res, next) {
console.log(req.body)
res.json(req.body)
})
Example 2: app.post (req res) get data
const express=require('express');
const app=express();
app.post("/register/",function(req,res){
var bodyStr = '';
req.on("data",function(chunk){
bodyStr += chunk.toString();
});
req.on("end",function(){
res.send(bodyStr);
});
});