use-http icon indicating copy to clipboard operation
use-http copied to clipboard

[Feature Request] Enabling access to the request's promise when using useFetch

Open uripre opened this issue 4 years ago • 2 comments

Hello,

Apologies in advance if I just missed this feature - but essentially I wanted to get a callback for when the request is finished in the hook. It is useful sometimes when you want something to happen in the component when the request completes, but you don't want it to run on every render.

Something in the lines of: const fetchState = useFetch('http://google.com'); fetchState.promise.then(() => {...});

Happy to hear thoughts and feedback.

uripre avatar Nov 12 '20 14:11 uripre

Have you tried const { get } = useFetch('https://google.com'); get().then(() => {...})?

alex-cory avatar Nov 16 '20 22:11 alex-cory

Admittedly no, thanks for the reply, I might have misunderstood the API. If I use a dependency array, Should I just call get() again?

uripre avatar Nov 16 '20 23:11 uripre