diff options
Diffstat (limited to 'quotes/public')
-rw-r--r-- | quotes/public/index.html | 6 | ||||
-rw-r--r-- | quotes/public/script.js | 17 |
2 files changed, 7 insertions, 16 deletions
diff --git a/quotes/public/index.html b/quotes/public/index.html index abe85cc..0c7b327 100644 --- a/quotes/public/index.html +++ b/quotes/public/index.html @@ -14,13 +14,13 @@ <title>Zitate</title> </head> <body> - <form class="pure-form pure-form-stacked" action="api/submit" method="post"> + <form class="pure-form pure-form-stacked" action="api/add" method="post"> <fieldset> <legend>Zitate</legend> <label for="author">Author</label> - <select name="author" id="author"></select> + <select name="author" id="author" required></select> <label for="quote">Zitat</label> - <input name="quote" type="text" id="quote" placeholder="Zitat" /> + <input name="quote" type="text" id="quote" placeholder="Zitat" required /> <button type="submit" class="pure-button pure-button-primary">Hinzufügen</button> </fieldset> </form> diff --git a/quotes/public/script.js b/quotes/public/script.js index 3fbc676..7a87486 100644 --- a/quotes/public/script.js +++ b/quotes/public/script.js @@ -6,7 +6,7 @@ function append(response) { response.forEach((elem) => { dropdown.insertAdjacentHTML( "beforeend", - `<option ${elem["id"]}>${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${ + `<option value="${elem["id"]}">${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${ elem["surname"] }</option>` ); @@ -14,15 +14,6 @@ function append(response) { } // 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); +fetch("/auth/api/list") + .then((response) => response.json()) + .then((response) => append(response)); |