2024-12-20 22:09:12 +00:00

15 lines
514 B
JavaScript

//fetch: send a url request, client side rendering
//update the list, by default: fetch uses get
fetch('/get-todos', {method: 'GET'}). then((response) => {
response.json(). then((data) => {
const ol = document.querySelector('ol');
data.forEach((item) => {
//Create li
const li = document.createElement('li');
//add text to li
li.textContent = item;
//add li underneath (child) ol
ol.appendChild(li);
})
});
});