-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (29 loc) · 1.09 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const form = document.getElementById('submissionForm');
form.addEventListener('submit', formSubmit);
async function formSubmit(event) {
event.preventDefault();
const formData = new FormData(form);
const email = formData.get('email');
const githubRepoUrl = formData.get('githubRepoUrl');
const data = JSON.stringify({ email, githubRepoUrl });
try {
const response = await fetch('https://7pu263mpcarw3lhazop5ec7u7e0bclzu.lambda-url.us-east-1.on.aws/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: data,
});
let responseData;
if (response.ok) {
responseData = await response.json();
// Added alert to confirm that the form was submitted successfully, would typically redirect to another page
alert('Form submitted successfully!');
} else {
throw new Error('Request failed: status ' + response.status);
}
} catch (error) {
console.log('An error occurred:', error);
}
form.reset();
}