Handle null and undefined headers
75lb opened this issue · comments
Thanks for reporting! Using headers with value null
or undefined
should indeed work like it does in the browser implementation of the fetch api.
Can you submit a PR with a testcase and the fix? Otherwise I'll try to include it in the next release myself, but I am not sure how soon that will be right now.
Hi, I have a related question.
Shouldn't boolean headers be supported as well ? They work in node-fetch.
Btw thanks for the package, saved me some time!
Hi @DavidKrpt yes indeed, the goal was to replicate the request which would be executed by node-fetch or the fetch implementation of the browsers.
Therefore the expected output for fetchToCurl("https://github.com", { headers: { "x-test": null } })
should be curl 'https://github.com' -H "x-test: null"
in my opinion.
Shouldn't boolean headers be supported as well ?
Good catch :) These also do not work properly right now. Since Browser just output the string true
and false
for booleans the same fix should be applied for them.
just for reference: potential fix in #37