From d9bcdc36a60074fd78718ea8f7c4745d640e3b4f Mon Sep 17 00:00:00 2001 From: Alex Pavlov Date: Wed, 19 May 2021 20:38:33 +0300 Subject: [PATCH] fix: Buffer is allow as body without encoding to string (#223) Co-authored-by: Justin Beckwith --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4bdc093..a102f28 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,7 +105,9 @@ function requestToFetchOptions(reqOpts: Options) { // Set body to JSON representation of value options.body = JSON.stringify(reqOpts.json); } else { - if (typeof reqOpts.body !== 'string') { + if (Buffer.isBuffer(reqOpts.body)) { + options.body = reqOpts.body; + } else if (typeof reqOpts.body !== 'string') { options.body = JSON.stringify(reqOpts.body); } else { options.body = reqOpts.body;