From dd50ad615957b91cd36aef6da2b3f9ed278f9160 Mon Sep 17 00:00:00 2001 From: mistval Date: Sat, 17 Aug 2024 11:13:07 -0400 Subject: [PATCH] default null body to empty stream --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2f52f82..cfc03ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import type { Request as NodeFetchRequestType } from 'node-fetch'; +import { Readable } from 'stream'; import { FormData } from 'formdata-node'; import { getNFCResponseClass as getNFCResponseClass } from './classes/response.js'; import { MemoryCache } from './classes/caching/memory_cache.js'; @@ -94,7 +95,7 @@ async function getResponse( if (shouldCache) { const cacheSetResult = await fetchCustomization.cache.set( cacheKey, - bodyStream!, + bodyStream ?? Readable.from(Buffer.alloc(0)), serializedMeta, ); @@ -102,7 +103,7 @@ async function getResponse( } return new NFCResponse( - bodyStream!, + bodyStream ?? Readable.from(Buffer.alloc(0)), serializedMeta, ejectSelfFromCache, false,