Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: Buffer is allow as body without encoding to string #223

Merged
merged 2 commits into from May 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Expand Up @@ -105,7 +105,9 @@ function requestToFetchOptions(reqOpts: Options) {
// Set body to JSON representation of value
options.body = JSON.stringify(reqOpts.json);
} else {
if (typeof reqOpts.body !== 'string') {
if (Buffer.isBuffer(reqOpts.body)) {
options.body = reqOpts.body;
} else if (typeof reqOpts.body !== 'string') {
options.body = JSON.stringify(reqOpts.body);
} else {
options.body = reqOpts.body;
Expand Down