I am trying to parse a String response from an API to JSON in ReactJS.
My string response looks like this:
[{"fromArea":"chocolate","toArea":"chocolate","distance":"100"},{"fromArea":"strawberry","toArea":"strawberry","distance":"200"},{"fromArea":"vanilla","toArea":"vanilla","distance":"300"}]
So far, I have tried:
JSON.parse(element.permission))
JSON.parse("\'"+element.permission+"\'")
I am getting error as:
AppliedPermissions.js:18 Uncaught (in promise) SyntaxError: Unexpected token o in JSON at position 1
Referred from:
Convert string array to array in javascript
Any help would be constructive.