diff --git a/index.js b/index.js index f0206cc..185dd2d 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ function md5(str) { async function getResponse(cacheDirPath, requestArguments, bodyFunctionName) { const [url, requestInit, ...rest] = requestArguments; - const requestParams = requestInit.body + const requestParams = requestInit && requestInit.body ? ({ ...requestInit, body: typeof requestInit.body === 'object' ? requestInit.body.toString() : requestInit.body }) : requestInit; diff --git a/package-lock.json b/package-lock.json index 5c30dba..83f7126 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-fetch-cache", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 50f23ad..b514309 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-fetch-cache", - "version": "1.0.5", + "version": "1.0.6", "description": "node-fetch with a persistent cache.", "main": "index.js", "scripts": {