Skip to content

Commit

Permalink
chore(internal): codegen related update (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 13, 2024
1 parent 9317296 commit bf4398d
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const client = new Riza({
});

async function main() {
const commandExecResponse = await client.command.exec({ code: 'print("Hello world!")' });
const response = await client.command.exec({ code: 'print("Hello world!")' });

console.log(commandExecResponse.exit_code);
console.log(response.exit_code);
}

main();
Expand All @@ -49,7 +49,7 @@ const client = new Riza({

async function main() {
const params: Riza.CommandExecParams = { code: 'print("Hello world!")' };
const commandExecResponse: Riza.CommandExecResponse = await client.command.exec(params);
const response: Riza.CommandExecResponse = await client.command.exec(params);
}

main();
Expand All @@ -66,17 +66,15 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const commandExecResponse = await client.command
.exec({ code: 'print("Hello world!")' })
.catch(async (err) => {
if (err instanceof Riza.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
const response = await client.command.exec({ code: 'print("Hello world!")' }).catch(async (err) => {
if (err instanceof Riza.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
}

main();
Expand Down Expand Up @@ -153,11 +151,11 @@ const response = await client.command.exec({ code: 'print("Hello world!")' }).as
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: commandExecResponse, response: raw } = await client.command
const { data: response, response: raw } = await client.command
.exec({ code: 'print("Hello world!")' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(commandExecResponse.exit_code);
console.log(response.exit_code);
```

### Making custom/undocumented requests
Expand Down

0 comments on commit bf4398d

Please sign in to comment.