4 a
Sun Apr 06 2025 17:52:01 GMT+0000 (Coordinated Universal Time)
Saved by
@exam3
<!DOCTYPE html>
<html>
<head>
<title>Fetch Example</title>
</head>
<body>
<h2>User Data</h2>
<table border="1" id="dataTable">
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</table>
<script>
fetch('https://jsonplaceholder.typicode.com/users')
.then(response => response.json())
.then(data => {
const table = document.getElementById("dataTable");
data.forEach(user => {
const row = table.insertRow();
row.innerHTML = `<td>${user.name}</td><td>${user.email}</td>`;
});
})
.catch(err => console.log("Error:", err));
</script>
</body>
</html>
content_copyCOPY
Comments