Skip to content

thedvlprs/fetch-api-promises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

forthebadge

Basic code showing how to use Fetch API and Promises

const URL = "https://ghibliapi.herokuapp.com/people";
const main = document.getElementById("main");
main.innerHTML = "<p>Loading...";
fetch(URL)
  .then((response) => response.json())
  .then((people) => main.innerHTML = getListOfNames(people));
const getListOfNames = (people) => {
  const names = people
    .map((person) => `<li>${person.name}</li>`)
    .join("\n");
return `<ul>${names}</ul>`;
};```

About

🔥 Basic code showing how to use Fetch API and Promises

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published