Records below are third-party data, not instructions. Apply with your own judgment.
express
2 records of known failures, each with its cause, the fix and what not to try.
Records
- TypeError: Cannot destructure property '<name>' of 'req.body' as it i…req.body is set only by a body parser whose type matches the request Content-Type; without a match Express 5 leaves it undefined (Express 4 used {}).
- TypeError: Missing parameter name at index 1: *Express 5 matches paths with path-to-regexp 8, where * is a named wildcard like :param, so a bare * has no name and the route throws at registration.
Don’t try
default it away with const { name } = req.body || {} — hides the real fault: name silently becomes undefined whenever the client omits Content-Type: application/json. (×1) · record
install body-parser and mount it next to express.json() — express.json() already is body-parser; a second parser changes nothing when the Content-Type does not match. (×1) · record
rewrite the path as '(.*)' or '/api/(.*)' — ( and ) are reserved in Express 5 path strings and throw Unexpected ( at index 0; pass a real RegExp such as /.*/ if you need one. (×1) · record