index.js 836 B

1234567891011121314151617181920212223242526
  1. const inputUsername = document.getElementById("input-signup-username");
  2. const inputPassword = document.getElementById("input-signup-password");
  3. const buttonSignup = document.getElementById("button-signup");
  4. const resultTxt = document.getElementById("result-text");
  5. buttonSignup.onclick = async () => {
  6. const username = inputUsername.value;
  7. const password = inputPassword.value;
  8. // console.log(username);
  9. // console.log(password);
  10. const res = await fetch("http://127.0.0.1:8080/api/user/signup", {
  11. method: "POST",
  12. headers: {
  13. "Content-Type": "application/json"
  14. },
  15. body: JSON.stringify({
  16. "username": username,
  17. "password": password
  18. })
  19. });
  20. const resJson = await res.text();
  21. resultTxt.textContent = `${res.status} ${resJson}`;
  22. };