Answers for "Unexpected token a in JSON at position"

0

Unexpected token a in JSON at position

JSON.parse(JSON.stringify(userData))
Posted by: Guest on May-07-2022
0

Unexpected token W in JSON at position 0

Unexpected token W in JSON at position 0

It's because a simple string (plain text) is returned as the response. The text is not a valid JSON. So when you try to do res.json(), it calls JSON.parse(data). Try and do it with the string you provided, and you will get the same error.

use res.text() instead of res.json()
Posted by: Guest on May-16-2022

Code answers related to "Unexpected token a in JSON at position"

Code answers related to "Javascript"

Browse Popular Code Answers by Language