close

[Fixed] Uncaught (in promise) SyntaxError: Unexpected end of JSON input

Today We are Going To Solve Uncaught (in promise) SyntaxError: Unexpected end of JSON input in Javascript. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Uncaught (in promise) SyntaxError: Unexpected end of JSON input Error?

  1. How to Fix Uncaught (in promise) SyntaxError: Unexpected end of JSON input Error?

    To Fix Uncaught (in promise) SyntaxError: Unexpected end of JSON input Error just add this code in the headers. Just add this in the headers by API developer and your error will be removed. "Access-Control-Allow-Origin" : "*", "Access-Control-Allow-Credentials" : true

  2. Uncaught (in promise) SyntaxError: Unexpected end of JSON input

    To Fix Uncaught (in promise) SyntaxError: Unexpected end of JSON input Error just Use res.send(). use res.send just like below and it will help you. res.send({a: "b"});

Solution 1 : add this code in the headers

Just add this in the headers by API developer and your error will be removed.

"Access-Control-Allow-Origin" : "*", 
"Access-Control-Allow-Credentials" : true 

Solution 2 : Use res.send()

use res.send just like below and it will help you.

res.send({a: "b"});

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment