Hiyve Components - v1.0.0
    Preparing search index...
    • Returns a fetch-compatible function that automatically attaches the authenticated user's access token as an Authorization: Bearer header.

      The returned function has the same signature as the global fetch. Use it for any request to your own backend that expects a Hiyve access token. When no user is signed in, the header is omitted and the request is sent unauthenticated.

      The returned function has a stable reference for the lifetime of the identity session, so it is safe to pass to useEffect / useCallback dependency arrays.

      Returns {
          (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
          (input: string | Request | URL, init?: RequestInit): Promise<Response>;
      }

      A fetch-compatible function.

        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

        • (input: string | Request | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: string | Request | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

      Error if called outside of an IdentityProvider.

      function Dashboard() {
      const authFetch = useAuthFetch();
      const [data, setData] = useState(null);

      useEffect(() => {
      authFetch('/api/dashboard')
      .then((r) => r.json())
      .then(setData);
      }, [authFetch]);

      return <pre>{JSON.stringify(data, null, 2)}</pre>;
      }