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

does post can auto fire?

Open bbaduser opened this issue 3 years ago • 3 comments

image can anyone tell me , the post fetch can run onmount or onupdate ?

bbaduser avatar Dec 30 '22 08:12 bbaduser

@bbaduser You can do it by calling the function post function from useEffect


const { loading,error,data = [] } = useFetch('...',options,[]);

useEffect(()=>{
  post();
},[]);

Are asking about doing it by default by useFetch it self as we do it for get ?

krishnasaga avatar Mar 10 '23 09:03 krishnasaga

Yes, const { data, loading } = useFetch('url', { method: 'post' }, [])

iamthesiz avatar Jun 15 '23 14:06 iamthesiz