FirebaseExtended / FirebaseExtended/firestore-leaderboards-codelab

updateScore method it is missing the documentPath

Open
#8 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5
Forks
6
PR merge metrics
No merged PRs in 30d

Description

### The error in my logs:

Error: Value for argument "documentPath" must point to a document, but was "SEwddLtelv69q8iaYTMj". Your path does not contain an even number of components.

### On step 3 where contains the code with the problem:

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);** <===== _HERE IS THE PROBLEM_
return doc.update({
score: newScore,
});
}

### How I fixed it:

Replace the old line with the new line -> const doc = firestore.collection("scores").doc(player.id);

Now the the documentPath is complete!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.