Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thedvlprs/fetch-api-promises

🔥 Basic code showing how to use Fetch API and Promises
https://github.com/thedvlprs/fetch-api-promises

demo fetch-api ghibli-api json promises

Last synced: about 1 month ago
JSON representation

🔥 Basic code showing how to use Fetch API and Promises

Awesome Lists containing this project

README

        

[![forthebadge](https://forthebadge.com/images/badges/it-works-why.svg)](https://forthebadge.com)

## Basic code showing how to use Fetch API and Promises

```javascript
const URL = "https://ghibliapi.herokuapp.com/people";
const main = document.getElementById("main");
main.innerHTML = "

Loading...";
fetch(URL)
.then((response) => response.json())
.then((people) => main.innerHTML = getListOfNames(people));
const getListOfNames = (people) => {
const names = people
.map((person) => `

  • ${person.name}
  • `)
    .join("\n");
    return `
      ${names}
    `;
    };```