When making a request to an API, the data returned to the front end is in the following format:
{ name: 'Fred',
data: [{'name': '"10\\" x 45\\" Nice Shirts (2-pack)"', 'price': '$30.25'}]
}
The data property is returned as a string, and I am attempting to convert it into an array using JSON.parse(response.data) so that I can utilize *ngFor
for iteration. However, I keep encountering an error.
Unexpected token ' in JSON at position 2
SyntaxError: Unexpected token ' in JSON at position 2 (at zone.js:1262:1)
at JSON.parse