Skip to content

Commit ad25d80

Browse files
committed
fix: guard blob and FormData
since they don't exist in Node
1 parent 0fefe08 commit ad25d80

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/FunctionsClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export class FunctionsClient {
5454
try {
5555
let _headers: Record<string, string> = {}
5656
let body: any
57-
if (functionArgs instanceof Blob || functionArgs instanceof ArrayBuffer) {
57+
if (
58+
(typeof Blob !== 'undefined' && functionArgs instanceof Blob) ||
59+
functionArgs instanceof ArrayBuffer
60+
) {
5861
// will work for File as File inherits Blob
5962
// also works for ArrayBuffer as it is the same underlying structure as a Blob
6063
_headers['Content-Type'] = 'application/octet-stream'
@@ -63,7 +66,7 @@ export class FunctionsClient {
6366
// plain string
6467
_headers['Content-Type'] = 'text/plain'
6568
body = functionArgs
66-
} else if (functionArgs instanceof FormData) {
69+
} else if (typeof FormData !== 'undefined' && functionArgs instanceof FormData) {
6770
// don't set content-type headers
6871
// Request will automatically add the right boundary value
6972
body = functionArgs

0 commit comments

Comments
 (0)