Last active
August 4, 2020 23:11
-
-
Save josedaniel/ae46bf7e8e94e0fb34e8d5a9fd8e83a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="todo-list"></div> | |
<script> | |
async function data(){ | |
const src = 'http://my-data.com/data.json'; | |
const response = await fetch(src); | |
return response.json(); | |
} | |
class TodoItem{ | |
constructor({title, description, completed}) { | |
this.title = title; | |
this.description = description; | |
this.completed = completed; | |
} | |
render() { | |
const { title, description, completed} = this; | |
return /* html */` | |
<div>${ title } ${ description } ${ completed }</div> | |
`; | |
} | |
} | |
data().then((todos) => { | |
let output = ``; | |
todos.forEach(element => { | |
output += new TodoItem(element).render(); | |
}); | |
document.querySelector('.todo-list').innerHTML(output); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment