I am very new to this, I keep having error "Uncaught SyntaxError: await is only valid in async function"
button.addEventListener('click', async => {
try {
const response = await fetch(
' https://student-challenge-api.herokuapp.com/students',
{
method: 'post',
json: true,
body: {
name: '',
last_name: ' '
},
}
);
console.log('Completed!', response);
} catch (err) {
console.error(`Error: ${err}`);
}
}); ```