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

Add note about empty request body #2098

Merged
merged 2 commits into from Aug 6, 2022
Merged

Conversation

mifi
Copy link
Sponsor Contributor

@mifi mifi commented Aug 3, 2022

Checklist

  • I have read the documentation.
  • I have included a pull request description of my changes.
  • I have included some tests.
  • If it's a new feature, I have included documentation updates in both the README and the types.

I literally spent hours trying to figure out why my requests were hanging, when sending a POST, but not when sending a GET. And only when using isStream: true, not with isStream: false

@sindresorhus
Copy link
Owner

We should either just gracefully handle this or throw an error.

@szmarczak
Copy link
Collaborator

The note is already here.

image

@mifi
Copy link
Sponsor Contributor Author

mifi commented Aug 4, 2022

Thanks! I missed that. Maybe I can add an example for the no-body use case too?

@szmarczak
Copy link
Collaborator

Buffer.alloc(0) is quite useless when you can just pass an empty string.

Feel free to move the note above if it's more noticeable.

@mifi
Copy link
Sponsor Contributor Author

mifi commented Aug 4, 2022

I updated the PR. An alternative solution to avoid issues like this could be to have one isStream option for the request and one for the response, maybe isRequestStream and isResponseStream.

@sindresorhus sindresorhus merged commit 5a7a4bd into sindresorhus:main Aug 6, 2022
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.

None yet

3 participants