Complete the code to create a basic route that responds with 'Hello World!'.
app.[1]('/', (req, res) => { res.send('Hello World!'); });
The get method defines a route that listens for GET requests on the specified path.
Complete the code to add a route that handles POST requests to '/submit'.
app.[1]('/submit', (req, res) => { res.send('Form submitted'); });
The post method is used to handle POST requests, typically for submitting data.
Fix the error in the route definition to correctly handle a DELETE request.
app.[1]('/item/:id', (req, res) => { res.send(`Deleted item ${req.params.id}`); });
The delete method handles DELETE requests, used to remove resources.
Fill both blanks to create a route that updates an item using PUT and sends a JSON response.
app.[1]('/item/:id', (req, res) => { res.[2]({ message: `Updated item ${req.params.id}` }); });
The put method handles update requests, and json sends a JSON response.
Fill all three blanks to create a route that handles GET requests with a dynamic parameter and sends a custom message.
app.[1]('/user/:name', (req, res) => { const userName = req.params.[2]; res.[3](`Hello, ${userName}!`); });
The get method handles GET requests, req.params.name accesses the dynamic URL part, and res.send() sends the response.