Skip to content

Commit

Permalink
Correct Eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
SviatoslavTaranenko committed Jan 8, 2024
1 parent 31e7d8c commit e93ed4d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
49 changes: 19 additions & 30 deletions docs/SviatoslavTaranenko/scripts/Games.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,16 @@ function createCardElement(game) {
return clone;
}

function fetchGamesData() {
return fetch('https://mmo-games.p.rapidapi.com/games', {
async function fetchGamesData() {
const response = await fetch('https://mmo-games.p.rapidapi.com/games', {
method: 'GET',
headers: {
'X-RapidAPI-Key': '1c3169c707mshb51bff34cbc9ff6p1749b9jsn648a19134256',
'X-RapidAPI-Host': 'mmo-games.p.rapidapi.com',
},
}).then((response) => response.json());
}

document.addEventListener('DOMContentLoaded', () => {
loadAndRenderGames();
});

async function loadAndRenderGames() {
const loadingOverlay = document.getElementById('loading-overlay');
loadingOverlay.style.display = 'flex';

try {
const response = await fetch('https://mmo-games.p.rapidapi.com/games', {
method: 'GET',
headers: {
'X-RapidAPI-Key': '1c3169c707mshb51bff34cbc9ff6p1749b9jsn648a19134256',
'X-RapidAPI-Host': 'mmo-games.p.rapidapi.com',
},
});

const gamesData = await response.json();

renderGames(gamesData.slice(0, 50));
} catch (error) {
console.error('Games loading error:', error);
} finally {
loadingOverlay.style.display = 'none';
}
});
const gamesData = await response.json();
return gamesData.slice(0, 50);
}

function renderGames(games) {
Expand All @@ -113,6 +88,20 @@ function renderGames(games) {
});
}

document.addEventListener('DOMContentLoaded', async () => {
const loadingOverlay = document.getElementById('loading-overlay');
loadingOverlay.style.display = 'flex';

try {
const gamesData = await fetchGamesData();
renderGames(gamesData);
} catch (error) {
console.error('Games loading error:', error);
} finally {
loadingOverlay.style.display = 'none';
}
});

function init() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ function createCardElement(game) {
return clone;
}

function loadAndRenderGames() {
const loadingOverlay = document.getElementById('loading-overlay');
loadingOverlay.style.display = 'flex';

fetchGamesData()
.then((gamesData) => {
renderGames(gamesData.slice(0, 50));
})
.catch((error) => {
console.error('Games loading error:', error);
})
.finally(() => {
loadingOverlay.style.display = 'none';
});
}

function fetchGamesData() {
return fetch('https://mmo-games.p.rapidapi.com/games', {
method: 'GET',
Expand All @@ -84,6 +68,33 @@ function fetchGamesData() {
}).then((response) => response.json());
}

document.addEventListener('DOMContentLoaded', () => {
loadAndRenderGames();
});

async function loadAndRenderGames() {
const loadingOverlay = document.getElementById('loading-overlay');
loadingOverlay.style.display = 'flex';

try {
const response = await fetch('https://mmo-games.p.rapidapi.com/games', {
method: 'GET',
headers: {
'X-RapidAPI-Key': '1c3169c707mshb51bff34cbc9ff6p1749b9jsn648a19134256',
'X-RapidAPI-Host': 'mmo-games.p.rapidapi.com',
},
});

const gamesData = await response.json();

renderGames(gamesData.slice(0, 50));
} catch (error) {
console.error('Games loading error:', error);
} finally {
loadingOverlay.style.display = 'none';
}
}

function renderGames(games) {
const cardContainer = document.querySelector('[data-type="card-container"]');

Expand All @@ -103,7 +114,7 @@ function renderGames(games) {
}

function init() {
loadAndRenderGames();

}

document.addEventListener('DOMContentLoaded', init);

0 comments on commit e93ed4d

Please sign in to comment.