node js express send get request from server code example
Example 1: 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);
});
});
Example 2: express url redirect
const app = require('express')();
app.get('/from', (req, res) => {
res.redirect('/to');
});
app.get('/to', (req, res) => res.send('Hello, World!'));