JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<ul id="todos"></ul>
CSS
.true {
color: green;
}
.false {
color: red;
}
JavaScript
async function getTodos() {
const todos = fetch('https://jsonplaceholder.typicode.com/todos')
.then(response => response.json())
.then(json => {
console.log(json)
const el = document.getElementById("todos")
for(let i = 0; i < json.length; i++) {
isCompleted = json[i].completed
el.innerHTML += `<li class='${isCompleted}'>${json[i].title}</li>`
}
})
}
getTodos();