Open DaveVanRijn opened 2 years ago
Hey @DaveVanRijn, nice observation! I totally agree with your point but I guess this hook was supposed to be a simple hook as intended by the creator. One solution that I can think of is to rename this current hook to something like useFetchJSON
or useFetchSimple
and create a new hook with the name useFetch
with all the above functionalities.
@shishirtiwari23 what are your views on this?
@DaveVanRijn would you mind working for the same? I'd assign you for this!
@Anuragtech02 and @DaveVanRijn , Yes the enhancements that you suggested are great but the useFetch hook that i created was meant to serve as simple fetch hook as @Anuragtech02 said and yes we should rename the hook to useFetchJSON and create a new hook named useFetch which will serve those enhancements
@Anuragtech02 and @shishirtiwari23, that would be an excellent solution as well. I'd be happy to create the full useFetch hook!
I’m interested in the full useFetch, as a customer I’d be happy to “use” it and potentially help refine it.
@jemccarthy13 Thanks for your support, it means a lot to us and welcome to "useReactHooks" we hope you find something "use"ful here !!
Hey @DaveVanRijn, hope you're doing well. Any updates on the full useFetch hook?
Hi all, I have been a bit ill lately and therefore haven't really had the time to work on the hook. I hope to be able to submit a PR next week!
No worries! Health first, take care :)
Right now the useFetch hook only supports basic GET requests since it only accepts an URL as parameter. For the hook to be generally useful it should at least support all parameters of the Fetch API, like a config object containing request method, body, headers etc.
Also, the hook expects JSON data as the response which limits the use of the hook. I think the hook should not assume JSON data is being fetched and should just return the Response object instead. Another option could be to use a generic type to determine the return value.
I would love to read other's opinion on this matter.