I am trying to setup the Pokemon API locally and having some issues with the API request that I am not sure how to resolve. This is my fetch request:
const fetchPokemon = async (input) => {
let pokemonRequestURL = pokemonProxyUrl + input;
try {
const res = await fetch(pokemonRequestURL.replace("http", "https"));
const data = await res.json();
if(data){
showLatestPokemon(data)
}
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
} catch (err) {
alert('Pokémon not Found')
}
};
Now I know this code works as I had it setup in Freecodecamp and the request went through fine. No issues at all. However now I am trying to set it up locally I just get the status (canceled) in my network tab. Does not matter if it is a pokemon or not.
I have added the code to VSCode and I am using the Live Server extension to load the page. Also I tried setting up on Github pages but had the same issue.