app.js
app.js
js
document.addEventListener('DOMContentLoaded', () => {
const studentList = document.getElementById('student-list');
const addStudentForm = document.getElementById('add-student-form');
fetch('http://localhost:3000/api/students', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, email })
})
.then(response => response.json())
.then(() => {
fetchStudents(); // Refresh the list of students
})
.catch(err => console.error('Error adding student:', err));
});