Build: The Web
💫

JSONPlaceholder - Blog Posts

JSONPlaceholder is a free online REST API that you can use to create fake data anytime you need it. It might be in a GitHub README, a Code Sandbox demo, Stack Overflow code examples, or simply to test things locally.
Add the following code to your index.html.
The body tag has the onload attribute which calls the function “run” once the body fully loads.
Add the following code to your style.css.
Add the following code to the script.js.
Select the main tag. In the function run, which is called once the body loads, fetch the api using fetch function.
The fetch() method in JavaScript is used to request the server and load the information in the webpages. The request can be of any APIs that returns the data of the format JSON or XML. This method returns a promise. Syntax: fetch( url, options )
Finally, add the fetched data to the main tag that was selected.
badge