1const app = require('express')();
2
3// The `res.redirect()` function sends back an HTTP 302 by default.
4// When an HTTP client receives a response with status 302, it will send
5// an HTTP request to the URL in the response, in this case `/to`
6app.get('/from', (req, res) => {
7 res.redirect('/to');
8});
9app.get('/to', (req, res) => res.send('Hello, World!'));
10
1// GET method route
2app.get('/', function (req, res) {
3 res.send('GET request to the homepage')
4})
5
6// POST method route
7app.post('/', function (req, res) {
8 res.send('POST request to the homepage')
9})
10