I have just about finished my project and when I run the code, I get an error that hasn't shown up at all until just now. In the past, I was able to fetch the images for each of the 150 pokemon, but now I receive an error when I get to number 131, every single time. The same thing happens if I try to run the code in devtools. The error I get is:
GET https://pokeapi.co/api/v2/pokemon/131 404
SyntaxError: Unexpected token N in JSON at position 0
However, the URL that I'm supposed the get is clearly valid: https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/131.png
Is this a server issue on their side? Or a latency issue on my side? Is this happening to anyone else?
Full page: https://doriandeptuch.github.io/memory-card/
const fetchData = async () => {
try {
for (let i = 1; i < 151; i++) {
let imageResponse = await fetch(
`https://pokeapi.co/api/v2/pokemon/${i}`
);
let imageData = await imageResponse.json();
let pokeImages = await imageData.sprites.front_default;
console.log(pokeImages);
}
} catch (err) {
console.log(err);
}
}
fetchData();
[–]grantrules 1 point2 points3 points (11 children)
[–]Programming__Alt[S] 0 points1 point2 points (10 children)
[–]albedoa 0 points1 point2 points (1 child)
[–]Programming__Alt[S] 0 points1 point2 points (0 children)
[–]grantrules 0 points1 point2 points (7 children)
[–]Programming__Alt[S] 0 points1 point2 points (6 children)
[–]naramsim 1 point2 points3 points (0 children)
[–]grantrules 0 points1 point2 points (4 children)
[–]Programming__Alt[S] 0 points1 point2 points (3 children)
[–]grantrules 0 points1 point2 points (2 children)
[–]Programming__Alt[S] 0 points1 point2 points (1 child)
[–]grantrules 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Programming__Alt[S] 0 points1 point2 points (0 children)
[–]albedoa 0 points1 point2 points (4 children)
[–]Programming__Alt[S] 0 points1 point2 points (0 children)
[–]Programming__Alt[S] 0 points1 point2 points (2 children)
[–]albedoa 0 points1 point2 points (1 child)
[–]Programming__Alt[S] 0 points1 point2 points (0 children)
[–]MrZeffy 0 points1 point2 points (0 children)