mirror of
https://github.com/Alvin-Zilverstand/pokedex.git
synced 2026-12-02 19:11:22 +01:00
Refactor Pokémon data fetching and validation logic; improve error handling and logging
This commit is contained in:
1 parent
6e06965bc0
commit
5b4fcda9d6
4 files changed
+202
-14
No files matched your search
+4
-2
@@ -28,8 +28,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
function fetchPokemons() {
|
||||
console.log("Fetching Pokémon data from server...");
|
||||
fetch(`./get-pokemon.php`)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
.then((response) => response.text())
|
||||
.then((text) => {
|
||||
console.log("Server response:", text);
|
||||
const data = JSON.parse(text);
|
||||
if (Array.isArray(data)) {
|
||||
allPokemons = data;
|
||||
localStorage.setItem("pokemons", JSON.stringify(allPokemons));
|
||||
|
||||
Reference in new issue
Block a user