32 lines
830 B
JavaScript
32 lines
830 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)=>{
|
||
|
// if(time.trim() !== ""){
|
||
|
createOption(time);
|
||
|
// }
|
||
|
})
|
||
|
}
|