SyntaxError: Unexpected non-whitespace character after JSON data

The parser finished a JSON value and then found more characters. Two objects concatenated into the same response can cause this error, as can a debug message or warning after an otherwise valid payload. Read past the point where the first value closes.
For an ordinary JSON endpoint, return one complete JSON value. If the endpoint intentionally streams records, use the agreed format, such as newline-delimited JSON, and a reader that handles those records separately. Check which server or proxy component wrote any unexpected text.
Validate the complete response body. A validator can accept the first object after you copy it out, even though a second object or trailing log line is still present in the response that reached the browser.
const input = '{"ok":true}'; // A single complete JSON value const data = JSON.parse(input); console.log(data.ok);
Read from the end of the first valid JSON value to the end of the response and identify what the server appended.