express redicrect code example
Example 1: express redirect
res.redirect('/foo/bar')
res.redirect('http://example.com')
res.redirect(301, 'http://example.com')
res.redirect('../login')
Example 2: express js redirect to url
app.get('/', function (req, res) {
res.send('GET request to the homepage')
})
app.post('/', function (req, res) {
res.send('POST request to the homepage')
})
Example 3: express js redirect to url
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('hello world')
})