aboutsummaryrefslogtreecommitdiff
path: root/profile/public/script.js
blob: 7c72b695d8065b215023ba9d418c22c62833a63b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const fs = document.querySelector("fieldset");

function appendQuestions(question) {
    const field = document.createElement("input");
    field.name = question.id;
    field.value = question.answer ?? "";
    field.placeholder = question.question;
    fs.insertBefore(field, fs.querySelector("button"));
}

fetch("api/questions")
    .then((response) => response.json())
    .then((response) => response.forEach(appendQuestions))
    .catch(console.error);