Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Last active October 14, 2022 18:21
Show Gist options
  • Save ajcrites/007b35898d89962f116e4877c22c9d96 to your computer and use it in GitHub Desktop.
Save ajcrites/007b35898d89962f116e4877c22c9d96 to your computer and use it in GitHub Desktop.
@Component(...)
export class ProfilePage {
...
async openGameApp() {
try {
const { token: userIdToken } = { token: '' } = await this.userService.getUserId();
Browser.open(
await lastValueFrom(
this.gameService.buildGameUrl(userIdToken)
)
);
} catch (err) {
this.errorService.reportError(err);
}
}
}
export class GameService {
...
buildGameUrl(userIdToken: string) {
return this.http.get(
this.urlBuilder.build(GAME_FORMAT, {
sessionId: this.sessionId,
}, {
queryParams: { userIdToken },
})
).pipe(
map(({ body: { formattedId } }): FormatUserIdResponse) => formattedId),
filter((formattedId) => !!formattedId),
map((formattedId) => `${ENV.GAME_WEB_APP_URL}?formattedId=${formattedId}`),
throwIfEmpty(() => new Error('Failed to format token'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment