fetch icon indicating copy to clipboard operation
fetch copied to clipboard

Consider not mutating provided opts object

Open celayale opened this issue 5 years ago • 2 comments

We are facing an issue when migrating from node-fetch to @zeit/fetch due to the fact that some of the properties in provided opts object are mutated before calling the decorated fetch function.

We are having issues mainly with headers, but I see the body is overwritten too.

Maybe it would be a good idea to copy provided opts and mutate the copy before passing to the wrapped fetch instead? It would remove these unexpected side effects.

I think I could try to provide the fix if you are ok with it.

celayale avatar Jun 07 '19 09:06 celayale

The implementation would be quite simple. Let me know if you want me to create the PR.

https://github.com/zeit/fetch/compare/master...celayale:feature/avoid-mutating-opts?expand=1

celayale avatar Jun 07 '19 13:06 celayale

+1

cgimeno avatar Jun 10 '19 11:06 cgimeno

Thank you for the report. We are archiving this project; you can read more details here: https://github.com/vercel/fetch/issues/83

Ethan-Arrowood avatar Nov 09 '23 22:11 Ethan-Arrowood