Skip to content

does post can auto fire? #382

Open
Open

Description

@bbaduser

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

Activity

  1. krishnasaga commented on Mar 10, 2023

    @krishnasaga
    Contributor

    @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 ?

  2. iamthesiz commented on Jun 15, 2023

    @iamthesiz
    Collaborator

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

  3. TannerS commented on Jan 7, 2025

    @TannerS

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

    Then how do you pass in the post body?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions