Files
moon-gaming/testacounts/app.js
T
2025-03-12 04:07:16 +00:00

43 lines
1.3 KiB
JavaScript

document.getElementById('loginForm').addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('loginUsername').value;
const password = document.getElementById('loginPassword').value;
fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Login successful');
} else {
alert('Login failed: ' + data.message);
}
});
});
document.getElementById('signUpForm').addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('signUpUsername').value;
const password = document.getElementById('signUpPassword').value;
fetch('/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Sign up successful');
} else {
alert('Sign up failed: ' + data.message);
}
});
});