React+Fetch+JsonPlaceholder

Hi guys, glad to see you again. Today we gonna talk about API and method fetch. Our project will work with real data from Server! The most popular API server for learning – is Jsonplaceholder. Lets open this site. Scroll down: Resources /posts 100 posts I`m pushing this button and we here we have a page with data. Ok. I`m grabbing this link and typing code. I am jumping to App, getting rid of this garbage… Now I am creating a new variable. This is async function- because if we work with API we should use async requests… Method json() It returns a promise which resolves with the result of parsing the body text as JSON. And finally we unloading our data to useState. We are creating use State and defining types. I`m grabbing one object from this page …and doing our work. { “userId“: 1, “id“: 1, “title“: “sunt a
Back to Top