This is why you're getting the "Unexpected token '<'" error, because the HTML is not valid JSON. To fix this issue, you need to check what the server is sending back and make sure it's returning a JSON object. One other gotcha that can result in "SyntaxError: Unexpected token" exception when calling JSON.parse() is using any of the following in the string values: New-line characters.

Understanding the Context