DEV Community

Discussion on: "Synchronous" fetch with async/await

Collapse
 
ahristoskov profile image
Alexander Hristoskov

I have the following problem, I have an express API endpoint which returns a token, although the promise .then() returns SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data like the Promise is still not resolved. Anyone else have such issues? I tried your code as well but with the same result.

Collapse
 
johnpaulada profile image
John Paul Ada

Hey! When I get this error, it's usually because the result I get isn't in JSON. Try await response.text() and check the response.