Complete the code to parse JSON data from a POST request in Express.
app.use(express.[1]());Express uses express.json() middleware to parse incoming JSON request bodies.
Complete the code to send a JSON response with a message.
res.[1]({ message: 'Hello, world!' });
Use res.json() to send a JSON response in Express.
Fix the error in the code to correctly access JSON data sent in the request body.
const name = req.body.[1];The JSON data sent in the request body is accessed via req.body. To get the 'name' field, use req.body.name.
Fill both blanks to create a POST route that receives JSON and sends a JSON response.
app.[1]('/submit', (req, res) => { const data = req.body; res.[2]({ received: data }); });
Use app.post to handle POST requests and res.json to send JSON responses.
Fill all three blanks to parse JSON, handle a POST request, and send a JSON response with a status code.
app.use(express.[1]()); app.[2]('/api/data', (req, res) => { const info = req.body; res.status([3]).json({ success: true, data: info }); });
Use express.json() middleware to parse JSON, app.post to handle POST requests, and res.status(200) to send a success status code.