You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this was the intended behavior, but useHttpsCallable's callCallable function returns a Promise<HttpsCallableResult<ResponseData> | undefined> which is being used to say "if the call succeeds return the expected ResponseData shape. But if it fails, STILL resolve the promise but with undefined.
I'd like to suggest that it should reject with the error if the call fails. That way your calling code can handle the err response the same way it handles the success data. Right now you have to write separate code that watches for changes to the hook's returned error object.
Specifically I'm trying to advance the user to the next page if the call succeeds, or call some logging and notification functionality if it fails. I'd like to be able to do this:
const[joinTeam,isJoiningTeam]=useHttpsCallable<Req,Res>(functions,'jointeam')()consthandleSubmitClick=async()=>{try{awaitjoinTeam()navigate('/team-page')}catch(err){logger.error('Error joining team',err)notificationContext.showErrorNotification({title: 'Unable to join team',message: err.userFriendlyMessage})}}
Since the promise returned by joinTeam currently doesn't ever reject, I can't handle the error this way.
It looks like all we'd have to do is to re-throw the error after updating the state here:
I'm not sure if this was the intended behavior, but useHttpsCallable's
callCallable
function returns aPromise<HttpsCallableResult<ResponseData> | undefined>
which is being used to say "if the call succeeds return the expectedResponseData
shape. But if it fails, STILL resolve the promise but with undefined.I'd like to suggest that it should reject with the error if the call fails. That way your calling code can handle the err response the same way it handles the success data. Right now you have to write separate code that watches for changes to the hook's returned error object.
Specifically I'm trying to advance the user to the next page if the call succeeds, or call some logging and notification functionality if it fails. I'd like to be able to do this:
Since the promise returned by joinTeam currently doesn't ever reject, I can't handle the error this way.
It looks like all we'd have to do is to re-throw the error after updating the state here:
react-firebase-hooks/functions/useHttpsCallable.ts
Line 41 in 09bf06b
I can look into submitting a PR but I'd like to get everyone's opinions on the change first since it's technically an API change.
Thanks for the great library!
The text was updated successfully, but these errors were encountered: