FirebaseExtended / FirebaseExtended/firestore-leaderboards-codelab
HTTP 500 error in UpdateScore
Open
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
I got an HTTP 500 error in UpdateScore, so I fixed it as follows.
async function updateScore(playerID, newScore, firestore) {
const playerSnapshot = await firestore.collection("scores")
.where("user", "==", playerID).get();
if (playerSnapshot.size !== 1) {
throw Error(`User not found in leaderboard: ${playerID}`);
}
const player = playerSnapshot.docs[0];
//const doc = firestore.doc(player.id);
const doc = firestore.collection('scores').doc(player.id);
return doc.update({
score: newScore,
});
}
Contributor guide
Assessment
This issue has not been assessed yet.