This repository has been archived on 2026-05-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Web-Dev-Old/nodeJS/Learning/05/public/js/todo.js
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);
})
});
});