-
Notifications
You must be signed in to change notification settings - Fork 55
Update the example code in user-trophy-list.md #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,8 @@ async function main() { | |||||||||||||
| const accessCode = await exchangeNpssoForAccessCode(process.env["NPSSO"]); | ||||||||||||||
| const authorization = await exchangeAccessCodeForAuthTokens(accessCode); | ||||||||||||||
|
|
||||||||||||||
| // 2. Get the user's `accountId` from the username. | ||||||||||||||
| // 2. Get the user's `accountId` from the username 'xelnia'. | ||||||||||||||
| // If you set `targetAccountId` to "me", it would download data for your own account. | ||||||||||||||
| const allAccountsSearchResults = await makeUniversalSearch( | ||||||||||||||
| authorization, | ||||||||||||||
| "xelnia", | ||||||||||||||
|
|
@@ -44,10 +45,23 @@ async function main() { | |||||||||||||
| .accountId; | ||||||||||||||
|
|
||||||||||||||
| // 3. Get the user's list of titles (games). | ||||||||||||||
| const { trophyTitles } = await getUserTitles(authorization, targetAccountId); | ||||||||||||||
|
|
||||||||||||||
| // Ensure all data is fetched when the totalItemCount exceeds the limit. | ||||||||||||||
| const allTitles: TrophyTitle[] = []; | ||||||||||||||
| let offset = 0; | ||||||||||||||
| while (true) { | ||||||||||||||
| const { totalItemCount, trophyTitles } = await getUserTitles( authorization, targetAccountId, { offset }); | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be more readable:
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, sorry for the late reply! I was caught up with a few other projects in March. Just wanted to check on the merging process for this repo—should I go ahead and update the commit, or were you planning to make the updates on your end? |
||||||||||||||
| if (!trophyTitles || trophyTitles.length === 0) { | ||||||||||||||
| break; | ||||||||||||||
| } | ||||||||||||||
| allTitles.push(...trophyTitles); | ||||||||||||||
| if (allTitles.length >= totalItemCount) { | ||||||||||||||
| break; | ||||||||||||||
| } | ||||||||||||||
| offset += trophyTitles.length; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| const games: any[] = []; | ||||||||||||||
| for (const title of trophyTitles) { | ||||||||||||||
| for (const title of allTitles) { | ||||||||||||||
| // 4. Get the list of trophies for each of the user's titles. | ||||||||||||||
| const { trophies: titleTrophies } = await getTitleTrophies( | ||||||||||||||
| authorization, | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be added to the example import block.