Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: send headers from .setHeaders to server #202

Merged
merged 1 commit into from
Sep 4, 2020

Conversation

vecerek
Copy link
Contributor

@vecerek vecerek commented Sep 1, 2020

Setting the request headers via the setHeaders method is broken. setHeaders only accepted the type Headers which is not a pure object, so destructuring it would not append the headers when calling fetch. One option would be to restrict the type of headers to Record<string, string>. However, that doesn't seem like the direction this package is taking, so the only other option is to handle all possible cases, i.e. Headers, string[][], Record<string, string> and undefined.

The PR also fixes the expected type of input to the setHeaders method, so it matches the type of RequestInit["headers"].

Unfortunately, I wasn't able to meaningfully test the added transformation logic via unit tests. I'm open to suggestions here 🙂

closes #203

@vecerek vecerek force-pushed the fix-request-headers branch from 03b1b88 to 7be5a4d Compare September 1, 2020 07:25
Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vecerek !

@jasonkuhrt jasonkuhrt changed the title Fix request headers fix: send headers from .setHeaders to server Sep 4, 2020
@jasonkuhrt jasonkuhrt merged commit e666f69 into graffle-js:master Sep 4, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Help] SetHeaders in TypeScript
2 participants