Internet_Programmirovanie_N.../Lab3/js/bebra.js
2023-12-15 09:18:21 +03:00

28 lines
767 B
JavaScript

const serverUrl = "http://localhost:8081";
const lst= document.querySelector("#time");
export async function getAllItemTime() {
const response = await fetch(`${serverUrl}/time`);
if (!response.ok) {
throw response.statusText;
}
return response.json();
}
function createOption( time){
const option = document.createElement("option");
option.textContent = time.timer;
//option.text = name;
//option.selected = isSelected;
lst.appendChild(option);
}
export default async function fillList(){
const data = await getAllItemTime();
lst.innerHTML ="";
// пустое значение
//lst.appendChild(createOption("выберите значение","", true));
data.forEach((time)=>{createOption(time)});
}