express router redirect code example
Example 1: javascript redirect
window.location.href = "http://mywebsite.com/home.html";
Example 2: express redirect to url
app.get('/', (req, res) => {
res.redirect('/about');
})
Example 3: express redirect
res.redirect('https://google.com')
Example 4: express js redirect to url
// GET method route
app.get('/', function (req, res) {
res.send('GET request to the homepage')
})
// POST method route
app.post('/', function (req, res) {
res.send('POST request to the homepage')
})