wulkanowy-web/files/js/homeworks.js
2021-01-09 23:11:12 +01:00

22 lines
No EOL
705 B
JavaScript

const homeworks_ = document.querySelector('#homeworks_');
myStorage = window.sessionStorage;
const getHomeworks = () => {
document.querySelector('#content').innerHTML = 'Here is homeworks (in my imagination)';
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/homeworks', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
})
}
homeworks_.addEventListener('click', getHomeworks);