mirror of
https://github.com/arthur-pbty/streaming-site.git
synced 2026-06-03 23:36:26 +02:00
22 lines
720 B
JavaScript
22 lines
720 B
JavaScript
document.getElementById('register-form').addEventListener('submit', function(event) {
|
|
event.preventDefault();
|
|
const email = document.getElementById('email').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
fetch('/register', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ email, password })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.token) {
|
|
localStorage.setItem('token', data.token);
|
|
window.location.href = 'index.html';
|
|
} else {
|
|
alert('Erreur lors de l\'inscription');
|
|
}
|
|
});
|
|
}); |