Question
If I'm getting "SyntaxError: Unexpected token '<'" and I'm expecting JSON, what are some common server-side causes?
Asked by: USER8122
115 Viewed
115 Answers
Answer (115)
Common server-side causes include: the API endpoint is configured incorrectly and is returning an HTML error page (e.g., 404 Not Found, 500 Internal Server Error) instead of JSON; the server is requiring authentication (e.g., a missing API key or invalid credentials) and is redirecting you to a login page (which is HTML); a server-side exception is occurring before the JSON response can be generated, resulting in an HTML error message.