Finish a JSON response

Take your time, follow the code and check your understanding.

The codeNode.js requests and async
res.writeHead(200, {"Content-Type":"application/json"});
res.write(JSON.stringify({ok:true}));
// The client keeps waiting.
Your answer4 min · no timer
What needs fixing?

Show solution and explanation

write sends bytes without ending the response. end marks the response as complete so the client can finish reading it.

Call res.end() when the response is complete.