-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from RaviTejaM9602/Milestone2
Hitting API Populate on Leader Board
- Loading branch information
Showing
7 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const leaderboard = document.querySelector('#items'); | ||
|
||
export const refreshLeaderboard = async () => { | ||
const response = await fetch( | ||
'https://us-central1-js-capstone-backend.cloudfunctions.net/api/games/BxXNm40rTdIjhpN9YGnO/scores', | ||
); | ||
const scoreText = await response.text(); | ||
const score = JSON.parse(scoreText); | ||
score.result.forEach((player) => { | ||
if (player.length === 0) { | ||
leaderboard.style.border = 'none'; | ||
} else { | ||
leaderboard.style.border = '2px solid rgb(36, 1, 1)'; | ||
leaderboard.innerHTML += `<li> | ||
${player.user} : ${player.score}</td> | ||
</li>`; | ||
} | ||
}); | ||
}; |