Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Fetch and Display data from any API/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#card{
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
p{
padding: 50px;
width: 200px;
height: 200px;
border: 1px solid;
margin: 20px;
}
h2{
text-align: center;
}
18 changes: 18 additions & 0 deletions Fetch and Display data from any API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" href="#">
<link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>How to Fetch and Display Data From an API</h2>
<div id="card">

</div>
</body>
<script src="script.js"></script>
</html>
9 changes: 9 additions & 0 deletions Fetch and Display data from any API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
async function get() {
const data = await fetch('https://fakestoreapi.com/products').then(res => res.json());
data.map(e => {
const para = document.createElement("p");
para.innerHTML = e.title;
document.getElementById("card").appendChild(para);
})
}
get();