Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
♻️ Current situation && 💡 Proposed solution
Fixes #3
Rather than letting the errors from a call to the fetch method get swallowed, we let them throw and let the user decide how to handle them. The code that was there previously seems handy for development, but is atypical for production.
This also leads to more reliable typing by avoiding returning an empty object in the error case.
I don't love copying types out of the
@types/tiny-json-http
module, but it doesn't expose the types we need and due to type overloading, I wasn't able to extract them with tricks likeParameters
orReturnType
.A cleaner fix would be to modify that module to export what we need, but I've only got so many hours in the day ;)
⚙️ Release Notes
[Consider making this a major release since this is technically a breaking change]
console.error
. This change removes that behavior and throws an exception to let the library user decide how to handle it.