Skip to content
Snippets Groups Projects
Commit 1d11cdbe authored by Subliminal Guy's avatar Subliminal Guy
Browse files

Add Minimal Data Fetching

parent 136d7974
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,25 @@ import data from "./helper/data.js";
const button = document.getElementsByClassName("main-button")[0];
button.addEventListener("click", () => {
console.log(data);
const existingDiv = document.getElementsByClassName("user-data")[0];
if (existingDiv) {
existingDiv.remove();
}
else {
const userDate = document.createElement("div");
userDate.className = "user-data";
userDate.innerHTML = `
<h1>${data[0].name}</h1>
<p>${data[0].username}</p>
<p>${data[0].email}</p>
`;
document.body.appendChild(userDate);
}
});
......
......@@ -3,6 +3,17 @@ body {
margin: 0;
background: deepskyblue;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.user-data {
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
justify-content: center;
margin-top: 20px;
color: navy;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment