Express_Crud_Example/public/main.js

19 lines
484 B
JavaScript
Raw Normal View History

2022-01-29 22:57:19 +01:00
const update = document.querySelector('#update-button');
update.addEventListener('click', _ => {
fetch('/quotes', {
method: 'put',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Marcus',
quotes: 'Ich bin ein Zitat5454!'
})
})
.then(res => {
if (res.ok) return res.json();
})
.then(response => {
window.location.reload(true);
})
})