Hi,
I'm connecting to the api with angular. It returns 200 as a result. But I am getting the following error. Why does this problem occur? What is the solution. Can you help me.
Error : unexpected token o in json at position 0 at json.parse
Hi,
I'm connecting to the api with angular. It returns 200 as a result. But I am getting the following error. Why does this problem occur? What is the solution. Can you help me.
Error : unexpected token o in json at position 0 at json.parse
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question.
Lakshna SPosted Dec 6, 2021, 10:14 AM
This error occurs when you parse some data where parsing is not required. The error means no parsing is required.
You can test this yourself, e.g. in Chrome's console:
JSON.parse()converts the input into a string.The
toString()method of JavaScript objects by default returns[object Object], resulting in the observed behavior.Solution: Remove the parsing.