Hope that helps Invariably, 99.9999999% of the time you get Unexpected token < in JSON as position 0 in the error, you did NOT receive json from the server. You received an HTML error message with your json following afterwards.
<p>PHP warning: blah blah blah</p>
Unexpected token i in JSON at position 6 - react redux app
Hope that helps I would guess that it is because the keys are unquoted, because the first key starts with an i. Some (most?) JSON parsers do not support unquoted keys as the specifications (RFC, ECMA) require keys to be quoted strings.
like below fixes the issue I am testing a server.js file through curl from cmd for post request where I am getting the above error. I saw many related question and answers but nothing solves my problem. Please provide me the solution. , You are using following body
SyntaxError: Unexpected token < in JSON at position 0 - React app in Rails API
wish help you to fix your issue I suspect your rails app is returning html when fetch is expecting JSON... The < character is indicative that an HTML string is being delivered, (the JSON parser is choking on HTML). Try dumping the response "as is" to see what you're receiving.