I’m having an issue in which changes made in search_for_pokemon does not reflect in the HTML portion.
let pokemon = {name: “”}
async function search_for_pokemon(passed_pokemon: any) { //handles searching for a game
let pokemon_name = searchQuery;
pokemon_name = pokemon_name.toLowerCase()
pokemon_api = https://pokeapi.co/api/v2/pokemon/${pokemon_name}
const response = await fetch(pokemon_api);
if (response.ok){
const poke_data = await response.json();
get_audio_and_picture(poke_data);
passed_pokemon.name = capitalize_name(pokemon_name);
pokemon_species_url = `https://pokeapi.co/api/v2/pokemon-species/${pokemon_name}`;
const pokemon_display = document.getElementById("display");
if (pokemon_display){
pokemon_display.style.display = "block";
}
const home_page = document.getElementById("homepage")
if (home_page){
home_page.style.display = "none"
}
}
}
function handle_search(){
search_for_pokemon(pokemon)
}
Search…
Clear
test
{pokemon.name}
For example, when pokemon is passed into the function, the name is changed when I console.log it, but the html portion does not reflect that, and the h1 remains blank.
Bevin Huynh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.