Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <input id="username"/>
- <input id="password" type="password"/>
- <button onclick="login()">login</button>
- <script>
- const username = document.getElementById("username");
- const password = document.getElementById("password");
- function login() {
- fetch("/api/login", {
- method: "post",
- headers: {
- "content-type": "application/json"
- },
- body: JSON.stringify({
- username: username.value,
- password: password.value
- }).then(function (response) {
- return response.json();
- }).then(function (result) {
- // TODO: show result to user
- }).catch(function (err) {
- // TODO: show error to user
- });
- });
- }
- </script>
- </body>
Add Comment
Please, Sign In to add comment