async function getListing(){
//performs an ajax request to the specified url to get pokemon data then pass
it to displayListing()
let url = "[Link]
try{
let response = await fetch(url);//1. Send http request and get response
let result = await [Link]();//2. Get data from response
displayListing(result);// 3. Do something with the data
}catch(e){
[Link](e);//catch and log any errors
}
function displayListing(pokeList){
//Renders a list of pokemon links to the page
let result = [Link]('#listing');
for(let record of [Link]){
[Link] +=
`<a class = "collection-item" id="${[Link]}" href="#"
onclick="getPokemon('${[Link]}')">${[Link]}</a> <br/>`;
}
}
async function getPokemon(pokemonName){
//given a pokemon name performs an ajax requests querying the pokemon's
// data and pass it to displayPokemon()
let url = "[Link]
url += `${pokemonName}`;
try{
let response = await fetch(url);//1. Send http request and get response
let pokemon = await [Link]();//2. Get data from response
displayPokemon(pokemon);
}catch(e){
[Link](e);//catch and log any errors
}
}
function displayPokemon(pokemon){
//renders details of the specified pokemon onto the page
let name = [Link];
[Link](name).href=`#${name}`;
let result = [Link]('#result');
for( let mon of [Link]) {
[Link] = `
${name}<br/>
<img src="${[Link].front_default}" alt="${[Link]}"
height="300" width="300" align="middle"><br/>
ID: ${[Link]}<br/>
Type: ${[Link]} <br/>
Weight: ${[Link]}<br/>
Height: ${[Link]}<br/> `
}
}