Kizspy | Question: 16
(Choose 3 answers)
Analyze the following Express.js code snippet and determine what it does when accessed via a web browser.
const express = require('express');const app = express();
app.use((req, res, next) => {
console.log('${req.method} request for '${req.url}'");next();});
app.get('/', (req, res) => {
res.send('Welcome to the homepage!');});
app.get('/about', (req, res) => { res.send('About us');});
app.use((req, res) => {
res.status(404).send('Page not found');
});
app.listen(3000, () => {
console.log('Server running on port 3000');});
A. It logs all incoming requests to the console.
B. It returns 'Welcome to the homepage!' for GET requests to the root URL.
C. It returns a 404 error for any undefined routes.
D. It only handles POST requests.