I\'d like to unit test a service, however, when running the test, I get the following error:
Uncaught (in promise) SyntaxError: Unexpected token o in
SyntaxError: Unexpected token o in JSON at position 1
Reasons as per the error :
Content-Type as JSON as a response from the API but you are getting response as a String start with alphabet o. Hence, It throws an error that Unexpected token o in JSON at position 1.text/html you need to parse, and if the response header is application/json it is already parsed for you.If you parse it again it will give you unexpected token o.If response is already a JSON Object then no need to use response.json().