How to fix `Unexpected token '<'`
SyntaxError: Unexpected token '<' is one of the most common JSON parsing errors on the web. It happens when JavaScript tries to parse HTML as JSON - that < character is usually the start of an HTML tag like <!DOCTYPE html> or <html>.
This error appears in your console when JSON.parse() encounters HTML instead of valid JSON data. It’s particularly frustrating because it often masks the real problem: your server returned an error page instead of the API response you expected.
Don't miss what's next. Subscribe to Odds & Todds: