Complete the code to import the Express module.
const express = require('[1]');
The Express module is imported using require('express').
Complete the code to parse JSON request bodies in Express.
app.use([1].json());Express has built-in middleware to parse JSON bodies: express.json().
Fix the error in the POST route handler to access the request body.
app.post('/data', (req, res) => { const data = req.[1]; res.send(data); });
The POST request body is accessed via req.body in Express.
Fill both blanks to create a test using supertest to POST JSON data.
request(app) .post('/submit') .send({ name: 'Alice' }) .expect([1], [2]);
The test expects a 200 status code and a JSON response.
Fill all three blanks to complete the test that sends JSON and checks the response.
test('POST /api/data', async () => { const response = await request(app) .post('/api/data') .set('[1]', 'application/json') .send({ key: 'value' }); expect(response.status).toBe([2]); expect(response.body).toHaveProperty('[3]'); });
The test sets the 'Content-Type' header to 'application/json', expects status 200, and checks the response body has the 'key' property.
