const dropdown = document.getElementById("answer"); const question_input = document.getElementById("question"); const question_label = document.getElementById("question_label"); dropdown.insertAdjacentHTML("beforeend", ''); function appendOption(response) { response.forEach((elem) => { dropdown.insertAdjacentHTML( "beforeend", ``, ); }); } function appendQuote(response) { response.forEach((elem) => { document .getElementById(elem["class"]) .insertAdjacentHTML( "beforeend", `
  • ${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${ elem["quote"] }
  • `, ); }); } fetch("/auth/api/list") .then((response) => response.json()) .then((response) => appendOption(response)); fetch("/poll/api/get") .then((response) => response.json()) .then((response) => { question_label.innerText = response["question"]; question_input.setAttribute("value", response["id"]); });