Skip to content

Commit

Permalink
fix: fix error in environments without TextEncoder (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and rattrayalex committed Jul 19, 2023
1 parent 3944555 commit 5b78e05
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core.ts
Expand Up @@ -128,9 +128,11 @@ export abstract class APIClient {
return Buffer.byteLength(body, 'utf8').toString();
}

const encoder = new TextEncoder();
const encoded = encoder.encode(body);
return encoded.length.toString();
if (typeof TextEncoder !== 'undefined') {
const encoder = new TextEncoder();
const encoded = encoder.encode(body);
return encoded.length.toString();
}
}

return null;
Expand Down

0 comments on commit 5b78e05

Please sign in to comment.