I am fetching todo list, I am wondering why it gives me undefined
when I do this
.then((response) => {
response.json();
}
it works with
.then(response => response.json())
Why is this happening?
Also, when I'm fetching the data, they are objects and I save them in array
completed: true,
id: 199,
title: "numquam repellendus a magnam",
userId: 10
},
etc..
Now, I have html template for this, I'd like to load this in my html where my styles are, how can I do this?
<div class="card">
<p>//Want Id here</p>
<strong>// Want Title here</strong>
</div>
fetching code:
let todos = [];
function fetchData() {
fetch('https://jsonplaceholder.typicode.com/todos').then(response => response.json())
.then((json) => {
todos = json;
console.log(todos);
})
}
fetchData();