Skip to content

Added withCredentials option.#36

Merged
developit merged 2 commits intodevelopit:masterfrom
crissto:withCredentials
Jun 12, 2020
Merged

Added withCredentials option.#36
developit merged 2 commits intodevelopit:masterfrom
crissto:withCredentials

Conversation

@crissto
Copy link
Copy Markdown
Contributor

@crissto crissto commented Jun 1, 2020

Forward withCredentials options to set credentials to 'include'.
If no withCredentials options, credentials will be 'same-origin' by default.

@crissto
Copy link
Copy Markdown
Contributor Author

crissto commented Jun 1, 2020

As per #30.

src/index.js Outdated
body: data,
headers: deepMerge(options.headers, customHeaders, true)
headers: deepMerge(options.headers, customHeaders, true),
credentials: options.withCredentials === true ? 'include' : 'same-origin'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As every byte matters, I'm suggesting a shorter solution:

credentials: options.withCredentials && 'include'

If options.withCredentials is true it will assign 'include' otherwise, the default option will be chosen which is 'same-origin'.

Also if this suggestion is somehow incorrect, you can make it shorter by simply removing === true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I will update the PR. Thanks!

@developit
Copy link
Copy Markdown
Owner

developit commented Jun 12, 2020

Nice work! I need to set up mocking to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants