upas-web-site/page-js.html

60 lines
2.5 KiB
HTML
Raw Permalink Normal View History

2024-10-09 15:13:24 +04:00
<html lang="ru">
</html>
<head>
<meta charset="utf-8">
<title>Моя страница</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link href="./node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="./node_modules/bootstrap-icons/font/bootstrap-icons.min.css" rel="stylesheet" />
<link rel="stylesheet" href="./css/style.css">
</head>
<body class="h-100 d-flex flex-column">
<header>
<nav class="navbar navbar-expand-md navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<i class="bi bi-app"></i>
Мой сайт
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
<div class="navbar-nav">
<a class="nav-link" href="./index.html">Главная страница</a>
<a class="nav-link" href="./page2.html">Вторая страница</a>
<a class="nav-link" href="./page3.html">Третья страница</a>
<a class="nav-link active" href="./page-js.html">JavaScript</a>
</div>
</div>
</div>
</nav>
</header>
2024-10-23 16:01:04 +04:00
<main id="students" class="container-fluid p-3">
2024-10-09 15:13:24 +04:00
</main>
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
Автор, 2022
</footer>
<script type="module">
2024-10-23 16:01:04 +04:00
const getPosts = async () => {
const students = document.getElementById("students");
const response = await fetch("http://localhost:3001/students?_embed=group");
const data = await response.json();
data.forEach(element => {
students.innerHTML += `<p>${element.last_name} - ${element.group.name}</p>`;
});
console.log(data);
};
document.addEventListener("DOMContentLoaded", () => {
getPosts();
});
2024-10-09 15:13:24 +04:00
</script>
</body>
</html>