mistval / node-fetch-cache

Node-fetch with built-in response caching.
MIT License
55 stars 9 forks source link

Include request body as string in hash #3

Closed vegar closed 4 years ago

vegar commented 4 years ago

Doing a POST with URLSearchParams as body, I noticed I got the same data back for all requests. Turned out that the JSON.stringify( ) just skips the body all together.

I solved this by checking if the body property is an object, and if so, I use the toString( ) representation as input to the hash-function. Either this will return the default [object object] representation, which is neither better nor worse than current behavior, or it will return a better representation like in the case of URLSearchParams.

mistval commented 4 years ago

Merged and published as v1.0.5. Thanks!