DEV Community

loading...

Discussion on: 5 React-Based Projects Every Beginner Must Try

Collapse
yugeroh profile image
Oliver James Aco

Hi @surajsrv11 I'm a newbie in React may I ask what API method did you used to fetch data in API. Because when I use fetch() in Web API they show me an error "JSON.parse: unexpected character at line 1 column 1 of the JSON data".

Collapse
surajondev profile image
Suraj Vishwakarma Author
fetch("https://disease.sh/v3/covid-19/all")
        .then(response => response.json())
        .then(data => (
            this.setState(
                {
                    covid_world : data
                }
            )
        ))
    }
Enter fullscreen mode Exit fullscreen mode

I use this method to get the data from the APIs and stored them into the state. If you want to see the whole project Covid19-info for detail.

Collapse
yugeroh profile image
Oliver James Aco

Thank you @surajsrv11 , I already figure it out I just forgot to insert the http protocol that's why the API didn't work. I already try your project and now I'm at the 2nd one.

Thread Thread
surajondev profile image
Suraj Vishwakarma Author

That's Great, keep developing 🔥🔥🔥

Some comments have been hidden by the post's author - find out more