-
Notifications
You must be signed in to change notification settings - Fork 17
fix: should handle empty content (HTTP 204) #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I wasn’t able to find any performance concerns with replacing res.json()
with JSON.parse(await res.text())
—they both seem to perform just as fast in both Firefox and Chrome. Thanks!
The only concern I used |
That’s true—I think that’s probably a better way to handle empty content.
That’s also fine to not tackle in this PR. For now I actually think it’s preferable this library does NOT catch errors, as that should bubble up to the parent function calling this. If this library tries to self-rescue, it gets into the realm of opinion (and limits its usage) |
Hm it still seems like lint & tests aren’t passing. If you have Prettier installed globally, it’s better to uninstall it and use the local copy. Also be sure to use the latest version of Node (18.x or 19.x) and re-install all dependencies with Also be sure to run |
|
Sorry, it will be fine now. |
Also, sorry—I didn’t realize #28 conflicted with this PR. Both PRs are needed! Checking the status length is important to do as well as the status code (which can be a shortcut). Apologies for merging that one first; it was accidental. |
a49784d
to
9c1d6c6
Compare
Changes
It won't throw error while handling response with no content, which is a common practice for DELETE method. Instead it will return empty in
data
orerror
.Checklist