Errors / JavaScript errors
Uncaught (in promise) SyntaxError: Unexpected end of JSON input
The page expected data from the server and got an empty answer.
Whatever the data was for does not appear; often a form looks sent and nothing happens.
Why it happens
response.json()on a response with no body: a 204, a failed request, or an error the server answered with nothing.JSON.parse("")on a value read from storage or a data attribute that is empty.- A response cut short by a timeout or a proxy.
How to fix it
- Check
response.okandresponse.statusbefore calling.json(); a 204 has no body by definition. - Guard empty strings before
JSON.parse, and catch the error where the data is optional. - Look at the request in the network tab: its status and size say which case it is.
Whose problem it is
Either the site's own code or a third party's, depending on where it comes from.
Does your site have it?
Free, no account. We open your page and four more in a clean Chrome and list every error like this one, with the page and the click that caused it. How the free page check works.
Often seen with
- Unexpected token '<'The browser asked for a script and got a web page instead, usually an error page or the home page.
- Uncaught (in promise)Something the page asked for in the background failed, and no code was there to handle it.