fetch SyntaxError: Unexpected token < in JSON at position 0 1

fetch SyntaxError: Unexpected token < in JSON at position 0

JSON.parse(theStringThatIsNotJson);

Here is what the above code is Doing:
1. We’re creating a variable called theStringThatIsNotJson and assigning it the value of a string that is not JSON.
2. We’re using the JSON.parse() method to try to parse the string.
3. We’re using the try…catch statement to catch the error that is thrown when JSON.parse() fails.
4. We’re logging the error to the console.

Similar Posts