From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

useEffect API calling

useEffect API calling

Welcome back, now let's discuss how we can call the APIs using useEffect hook. For calling the API, the first thing we need is actually the API. For this purpose, I am sharing this link with you which is jsonplaceholder.typico.com. This is a fake and free API's that we can use if we are just learning react or any other front-end development library. You can also create your own API's and it also provides by default some API's. Over here you have different routes for having 100 posts data, 500 comments data, 100 albums, 5,000 photos, todos and users. Let's pick this users one. I'm going to click on this. You can see this is the API link and we have all the users showing up in JSON. This is 10 users, mock and near to real world data which has a lot of options here. Now we are going to go in our console by pressing F12. We will go into the network tab and we reload it once again. Once you reload it, you are going to see the specific API being called. Just click on this and over here you…

Contents