Saturday, February 29, 2020

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



Error Blog 

Hi Guys ,
This blog is about the error   Uncaught (in promise) SyntaxError: Unexpected end of JSON input

Problem Statement

Unable to see the response from  a http call in react js .


Error Details 

error Log

ERROR DETAILS 
 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
    at <anonymous>:31:28




Solution

The http call does not return a json output . .


Code Changes 

Please validate the API endpoint .

  componentDidMount() {
        fetch(`/api/users`)
            .then(res => res.json())
            .then(result => this.setState({ users: result.users }))
    }
OUTPUT





Thanks for reading . Let me know your thoughts in the comments below    .

No comments:

Post a Comment

ec2-user@ec2 Permission denied