-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Can't return falsy value from response handler callback #58
Comments
Hey @itsgoingd,
Good catch!
It is indeed a bug, as I have the tendency to overlook the fact that From looking at the code, when the server returns a falsey json - or when the I'll investigate and fix it later today, thanks for reporting the issue! 👍 |
Just released v1.5.5 with the fix. 📦 |
Hey,
From the documentation:
This does not work if the returned value is
false
ornull
(probably any falsy value), the original request is passed on to the next promise instead.I took a quick look at the source and I believe it's caused by how the callback is run here
https:/elbywan/wretch/blob/master/src/resolver.ts#L89-L92
I'm not sure if it's an intentional choice, so when the callback does not return you won't lose the original request, or a bug. Even if it's intentional it might be better to explicitly check if the return value is
undefined
as returning some kind of "success" boolean might be a common use case.Fortunately the workaround is pretty straight-forward:
Thanks for this very nice library btw!
The text was updated successfully, but these errors were encountered: