You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 regels
1.4 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Login Form</title>
  7. </head>
  8. <body>
  9. <h1>Login</h1>
  10. <form id="loginForm">
  11. <label for="email">Username (Email):</label>
  12. <input type="text" id="email" name="email" required>
  13. <br>
  14. <label for="password">Password:</label>
  15. <input type="password" id="password" name="password" required>
  16. <br>
  17. <button type="button" id="loginButton">Login</button>
  18. </form>
  19. <script>
  20. document.getElementById('loginButton').addEventListener('click', function() {
  21. const email = document.getElementById('email').value;
  22. const password = document.getElementById('password').value;
  23. const data = {
  24. email: email,
  25. password: password
  26. };
  27. fetch('https://spt-moduled-symfony.ddev.site:8443/spt-core/api/login', {
  28. method: 'POST',
  29. headers: {
  30. 'Content-Type': 'application/json'
  31. },
  32. body: JSON.stringify(data)
  33. })
  34. .then(response => response.json())
  35. .then(data => {
  36. console.log(data);
  37. // Handle the response data as needed
  38. })
  39. .catch(error => {
  40. console.error(error);
  41. // Handle errors
  42. });
  43. });
  44. </script>
  45. </body>
  46. </html>