lesson 6
This commit is contained in:
15
nodeJS/Learning/05/public/js/todo.js
Normal file
15
nodeJS/Learning/05/public/js/todo.js
Normal file
@@ -0,0 +1,15 @@
|
||||
//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);
|
||||
})
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user