Complete the code to access the HTTP method from the request object.
const method = req.[1];The method property of the request object holds the HTTP method (GET, POST, etc.) used by the client.
Complete the code to get the URL path from the request object.
const path = req.[1];The url property contains the full URL path and query string sent by the client.
Fix the error in accessing the request headers property.
const headers = req.[1];The correct property name is headers, which holds all HTTP headers as an object.
Fill both blanks to extract the query string parameters from the request URL.
const url = require('url'); const queryObject = url.[1](req.[2], true).query;
Use url.parse to parse the request URL string and get the query parameters object.
Fill all three blanks to read JSON data sent in the request body using streams.
let body = ''; req.on('[1]', chunk => { body += chunk.toString(); }); req.on('[2]', () => { const data = JSON.[3](body); console.log(data); });
Listen for the 'data' event to collect chunks, 'end' event to finish, then parse the JSON string.