async function GetRoutes() {
const response = await fetch("api/route/all", {
method: "GET",
headers: { "Accept": "application/json" }
});
// если запрос прошел нормально
if (response.ok === true) {
// получаем данные
const players = await response.json();
let rows = document.querySelector("#players");
players.forEach(player => {
rows.append(listPlayers(player));
});
}
}
function listPlayers(player) {
const tr = document.createElement("div");
const name = document.createElement("div");
name.append(player.startPoint);
tr.append(name);
const surName = document.createElement("div");
surName.append(player.endPoint);
tr.append(surName);
const dName = document.createElement("a");
dName.setAttribute("href", "./user.html/api/user/" + player.userId);
dName.append(player.userId);
tr.append(dName);
const phone = document.createElement("div");
phone.append(player.userPhone);
tr.append(phone);
return tr;
}
GetRoutes();