Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The `useHttpsCallable` hook takes the following parameters:

- `functions`: `functions.Functions` instance for your Firebase app
- `name`: A `string` representing the name of the function to call
- `options`: An optional `object` with the following properties:
- `timeout`: A `number` representing the timeout in milliseconds for the function call. Default is 70000 ms.

Returns:

Expand Down
7 changes: 5 additions & 2 deletions functions/useHttpsCallable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Functions,
httpsCallable,
HttpsCallableResult,
HttpsCallableOptions,
} from 'firebase/functions';
import { useCallback, useState } from 'react';

Expand All @@ -20,7 +21,8 @@ export type HttpsCallableHook<

export default <RequestData = unknown, ResponseData = unknown>(
functions: Functions,
name: string
name: string,
options?: HttpsCallableOptions,
): HttpsCallableHook<RequestData, ResponseData> => {
const [error, setError] = useState<Error>();
const [loading, setLoading] = useState<boolean>(false);
Expand All @@ -31,7 +33,8 @@ export default <RequestData = unknown, ResponseData = unknown>(
): Promise<HttpsCallableResult<ResponseData> | undefined> => {
const callable = httpsCallable<RequestData, ResponseData>(
functions,
name
name,
options,
);
setLoading(true);
setError(undefined);
Expand Down