I would like to pass some data to a python code with javascript. I used the onclick function of a button configuring it like this:
const button = document.getElementById('btn-id');
button.addEventListener('click', async _ => {
try {
console.log(document.querySelector('.area-id'))
const response = await fetch('/', {
method: 'post',
body: document.querySelector('.area-id').innerText,
});
console.log('Completed!', response);
} catch(err) {
console.error(`ERRORE!`);
console.error(`Error: ${err}`);
}
});
However when I try to print the text of the textarea it comes out as an empty string... could someone help me?