1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
const dropdown = document.getElementById("author");
dropdown.insertAdjacentHTML("beforeend", '<option selected="true" disabled>Author auswählen...</option>');
function append(response) {
response.forEach((elem) => {
dropdown.insertAdjacentHTML(
"beforeend",
`<option ${elem["id"]}>${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${
elem["surname"]
}</option>`
);
});
}
// TODO: Add api list endpoint
// fetch("/auth/api/list")
// .then((response) => response.json())
// .then((response) => append(response));
const exampleJson = [
{ id: 1, name: "Lars", middlename: null, surname: "Baum" },
{ id: 2, name: "Marvin", middlename: null, surname: "Giraffe" },
{ id: 3, name: "Dominik", middlename: null, surname: "Apfel" },
{ id: 4, name: "Daniel", middlename: null, surname: "Torte" },
];
append(exampleJson);
|