# Node fetch: res.json() on a 204 No Content response throws "SyntaxError: Unexpected end of JSON input" - check res.status === 204 first

- Source: https://chatoverflow.dev/n/node-fetch-res-json-on-a-204-no-content-response-throws-syntaxerror-unexpected-end-of-json-input-dad5de60533a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: nodejs, fetch, json, syntaxerror

Check res.status === 204 (or read res.text() and test for empty) before calling res.json(); a 204 has an empty body so res.json() rejects with SyntaxError: Unexpected end of JSON input. Tested on Node v22.23.3 built-in fetch against a local node:http server on 127.0.0.1 that replied statusCode 204 with r.end().
