diff --git a/Existing_API_Collection/PokeAPI/index.html b/Existing_API_Collection/PokeAPI/index.html new file mode 100644 index 0000000..1016b32 --- /dev/null +++ b/Existing_API_Collection/PokeAPI/index.html @@ -0,0 +1,23 @@ + + + + + + PokeAPI + + + + + + +

PokeAPI

+ + + + + +
NameURL
+ + + + diff --git a/Existing_API_Collection/PokeAPI/index.js b/Existing_API_Collection/PokeAPI/index.js new file mode 100644 index 0000000..45694b5 --- /dev/null +++ b/Existing_API_Collection/PokeAPI/index.js @@ -0,0 +1,30 @@ +const API_URL = "https://pokeapi.co/api/v2/pokemon"; + +const addDataToPage = (value = []) => { + const pageData = value + .map( + (val) => + `${val.name}${val.url}` + ) + .join(""); + + const pokemonTag = document.getElementById("pokemon"); + pokemonTag.innerHTML += pageData; +}; + +const fetchData = async () => { + let url = ""; + if (document.getElementById("loadmore").value) { + url = document.getElementById("loadmore").value; + } else { + url = API_URL; + } + + const response = await fetch(url); + const responseBody = await response.json(); + addDataToPage(responseBody.results); + + document.getElementById("loadmore").value = responseBody.next; +}; + +fetchData(); diff --git a/Existing_API_Collection/README.md b/Existing_API_Collection/README.md index f13996f..2507098 100644 --- a/Existing_API_Collection/README.md +++ b/Existing_API_Collection/README.md @@ -12,3 +12,4 @@ |[Nasa API](./NasaAPI)|The APOD API provides access to the Astronomy Picture of the Day, which showcases a different astronomical image or photograph each day along with a brief explanation written by a professional astronomer.| |[CryptoCurrencies API](./CryptoCurrenciesAPIs)| It is giving the data about total trading of the popular coins in 24 hrs.| |[Giphy API](./GiphyAPI)|This API allows developers to integrate Giphy's vast library of GIFs into their own applications, websites, and services.| +|[PokeAPI](./PokeAPI/)| This API provides data regarding Pokemon and others related. |