Romaji to Kana Converter: React & Next.js — Chapter 4, Exercise 2 ===================================================================== TASK The /api/convert route returns a real 400 status for a missing or non-string romaji field. Send a real request with no body at all and explain, from real output, what actually happens before that check is ever reached. SOLUTION Sending a real POST request with genuinely no body at all: $ curl -X POST http://localhost:3000/api/convert \ -H "Content-Type: application/json" produces a real, unhandled server error -- a 500 response, not the clean 400 the route's own validation was written to return. The reason traces directly back to request.json() itself. Reproducing the same failure directly in Node, parsing an empty string exactly the way request.json() would internally: > JSON.parse('') Uncaught SyntaxError: Unexpected end of JSON input request.json() throws this same real SyntaxError the moment it tries to parse an empty body -- and that line runs BEFORE the route ever reaches its own "typeof romaji !== 'string'" check. The validation code was written correctly for the case where a body exists but has the wrong shape (e.g. {"romaji": 5} or {}); it was never given a chance to run at all for a body that isn't valid JSON in the first place, because the exception is thrown one line earlier, inside await request.json() itself. Since nothing in the route currently wraps that call in a try/catch, the thrown SyntaxError propagates all the way up and out of the handler, and Next.js reports it back to the client as a generic 500 Internal Server Error rather than the intended, specific 400. WHY THIS WORKS AS AN ANSWER ---------------------------- It reproduces the real failure with an actual, unguarded request rather than assuming the 400 check protects against every bad input, and traces the real root cause -- request.json() itself throwing on invalid JSON before validation code downstream ever gets a chance to run -- using a real, verified JSON.parse('') reproduction of the exact same failure.