Complete the code to create a POST route for '/submit'.
app.[1]('/submit', (req, res) => { res.send('Form submitted'); });
The post method defines a POST route in Express.
Complete the code to access JSON data sent in the POST request body.
app.post('/data', (req, res) => { const userData = req.[1]; res.json(userData); });
The body property contains data sent in the POST request body.
Fix the error in the code to parse JSON body data correctly.
const express = require('express'); const app = express(); app.[1](express.json()); app.post('/info', (req, res) => { res.send(req.body); });
The use method adds middleware to parse JSON bodies before routes handle requests.
Fill both blanks to send a JSON response with a status code 201.
app.post('/create', (req, res) => { res.[1](201).[2]({ message: 'Created' }); });
Use status(201) to set the HTTP status code and json() to send a JSON response.
Fill all three blanks to create a POST route that reads JSON body, logs it, and responds with a success message.
app.[1]('/log', (req, res) => { const data = req.[2]; console.log(data); res.[3]({ status: 'success' }); });
Define a POST route with post, access the JSON body with body, and respond with JSON using json.
