fetch('./server.json')
.then(response => response.json())
.then(data => console.log(data))
.catch(err => console.error(err));
const fetchData = async () => {
try {
const res = await fetch("js/data.json");
data = await res.json();
displayData(data);
} catch (e) {
console.log("something went wrong!", e);
}
};
fetchData();
const todoUrl ='https://jsonplaceholder.typicode.com/todos';
function getAllTodos(){
return new Promise((resolve => {
fetch(new Request(todoUrl)).
then( res => {
return res.json();
})
.then(data => {resolve(data);
});
}))
}