Update sdk/js/player/query
parent
532f2e876c
commit
68b0bf3e60
@ -3,13 +3,13 @@
|
|||||||
## Example
|
## Example
|
||||||
```ts
|
```ts
|
||||||
import { getPlayer } from "restfulmc-lib";
|
import { getPlayer } from "restfulmc-lib";
|
||||||
import type { CachedPlayer } from "restfulmc-lib/dist/index";
|
import type { CachedPlayer, RestfulMCAPIError } from "restfulmc-lib/dist/index";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const player: CachedPlayer = await getPlayer("Rainnny");
|
const player: CachedPlayer = await getPlayer("Rainnny");
|
||||||
console.log(`Hello ${player.username}, your UUID is ${player.uniqueId}!`);
|
console.log(`Hello ${player.username}, your UUID is ${player.uniqueId}!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if ((err as ErrorResponse).code == 404) {
|
if ((err as RestfulMCAPIError).code == 404) {
|
||||||
console.error("Player with UUID or username not found.");
|
console.error("Player with UUID or username not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user