HttpService
Unique ids and JSON helpers. Games can’t make web requests.
- Get it:
import { HttpService } from '@rally/sdk'
Methods
Section titled “Methods”generateGuid
Section titled “generateGuid”generateGuid(): stringA random UUID (version 4), such as '3b241101-e2bb-4255-8caf-4136c566a962'.
jsonEncode
Section titled “jsonEncode”jsonEncode(value: unknown): stringvalue as JSON text (JSON.stringify).
jsonDecode
Section titled “jsonDecode”jsonDecode<T = unknown>(json: string): TParses JSON text (JSON.parse). Throws on invalid JSON.
Examples
Section titled “Examples”Give each round an id
Section titled “Give each round an id”import { HttpService, print } from '@rally/sdk';
const roundId = HttpService.generateGuid();const summary = HttpService.jsonEncode({ roundId, winners: ['Ann', 'Bo'] });const parsed = HttpService.jsonDecode<{ roundId: string; winners: string[] }>(summary);print(parsed.winners.length);