In the process of developing an API using the next.js app router, I encountered an issue. Specifically, I was successful in parsing the data with const res = await request.json()
when the HTTP request type was set to post
. However, I am facing difficulties when the HTTP request is changed to get
.
⨯ SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at parseJSONFromBytes (node:internal/deps/undici/undici:6571:19) at successSteps (node:internal/deps/undici/undici:6545:27) at specConsumeBody (node:internal/deps/undici/undici:6551:9) at NextRequest.json (node:internal/deps/undici/undici:6442:18) at GET (webpack-internal:///(rsc)/./src/app/api/submit-lead-by-get-method/route.ts:12:31) Does anyone have insights on what might be causing this issue and how it can be resolved?
I find myself at a standstill here as I believe that regardless of the HTTP method used for the endpoint, the request should be able to parse the data without any hindrances.