This commit is contained in:
Jacob Nguyen
2023-12-13 14:23:17 -06:00
parent 9a0cd1ef30
commit ea95995857
2 changed files with 10 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ REST API client for managing discord application commands.
## features
- Optionally typed responses
- view an example (here)[../poster/test/spec.ts]
- view an example [here](../poster/test/spec.ts)
- Typed options
- Simple! (sort of)
- ClojureScript + Typescript
@@ -17,7 +17,7 @@ import poster from '@sern/poster';
const send = poster.client("token", "appid");
const req = await send("global/get-all", {
//options
});
console.log(await req.json());
@@ -44,3 +44,10 @@ This package is pretty simple. Create a new client and call one of the "endpoint
Documentation for these routes are specified in the discord api documentation,
starting [here.](https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands)
## Extra
For fully typed responses (which i do not recommend), cast your response.
An example exists [here] (../poster/test/spec.ts). Also I don't know if they work for every single type, if they dont, I will fix it if it is a serious issue.

View File

@@ -6,7 +6,7 @@ const send = poster.client("token", "appid");
const req = await send("global/get-all", {
}) as TypedResponse<GlobalPut>;
}) as TypedResponse<GlobalPut>; //cast for full typed safety
if(poster.isOk<GlobalPut>(req)) {
req.json().then(s => s?.map(v => v.name))