Return a meaningful status

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

The codeNode.js requests and async
res.writeHead(200, {"Content-Type":"application/json"});
res.end(JSON.stringify({error:"Product not found"}));
Your answer4 min · no timer
What needs fixing?

Show solution and explanation

An error-shaped JSON body can still be an HTTP success. Set the correct status so clients can use response.ok and error handling.

Use a 404 response status for a missing product.