diff --git a/index.js b/index.js index 6b8be58..7a156fb 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,12 @@ function md5(str) { } async function getResponse(cacheDirPath, requestArguments, bodyFunctionName) { - const cacheHash = md5(JSON.stringify(requestArguments) + bodyFunctionName); + const [url, requestInit, ...rest] = requestArguments; + const requestParams = requestInit.body + ? Object.assign({}, requestInit, {body: typeof requestInit.body === 'object' ? requestInit.body.toString() : requestInit.body}) + : requestInit; + + const cacheHash = md5(JSON.stringify([url, requestParams, ...rest]) + bodyFunctionName); const cachedFilePath = path.join(cacheDirPath, `${cacheHash}.json`); try {