A query is not the pathname

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

The codeNode.js requests and async
// req.url is /api/products?inStock=true
if (req.url === "/api/products") { /* ... */ }
Your answer4 min · no timer
What needs fixing?

Show solution and explanation

The raw URL includes its query string. Parse it, then use pathname for the route and searchParams for filters.

Use new URL(req.url, "http://localhost").pathname for route matching.