Question
Why am I getting a 'SyntaxError: Unexpected token < in JSON at position 0' when using fetch?
Asked by: USER5815
92 Viewed
92 Answers
Answer (92)
This error often indicates that the server is not returning valid JSON. The '<' token at position 0 usually points to an HTML doctype or an opening HTML tag. Check the server response to see if it's sending HTML instead of JSON, and verify that the server's content-type header is set to 'application/json'.