Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhighway committed Oct 30, 2023
0 parents commit 05ad66e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Persons</title>
</head>

<body>
<h1>Personen</h1>

<table id="persons"></table>

<script>
function show(data) {
let personsTableHtml =
`<tr>
<th>Voornaam</th>
<th>Achternaam</th>
</tr>`;

// Loop to access all rows
for (let r of data) {
personsTableHtml += `<tr>
<td>${r.firstName}</td>
<td>${r.lastName}</td>
</tr>`;
}

// Setting innerHTML as tab variable
document.getElementById("persons").innerHTML = personsTableHtml;
}

function loadPersons() {
fetch('http://localhost:8080/api/person/all')
.then(res => res.json())
.then(data => {
console.log('response', data);
show(data);
})
.catch(error => {
console.log('error', error);
// handle the error
});
}

loadPersons();
</script>

</body>

</html>

0 comments on commit 05ad66e

Please sign in to comment.