FunctionsClient
Client for invoking Supabase Edge Functions.
class FunctionsClient { }
constructor(url: string, { headers, customFetch, region }?: {
headers?: Record<string, string>;
customFetch?: Fetch;
region?: FunctionRegion;
});protected fetch: Fetch;
protected headers: Record<string, string>;
protected url: string;
invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>;
setAuth(token: string): void;
§Constructors
§
new FunctionsClient(url: string, { headers, customFetch, region }?: {
[src]headers?: Record<string, string>;
customFetch?: Fetch;
region?: FunctionRegion;
})Creates a new Functions client bound to an Edge Functions URL.
@example
import { FunctionsClient, FunctionRegion } from '@supabase/functions-js'
const functions = new FunctionsClient('https://xyzcompany.supabase.co/functions/v1', {
headers: { apikey: 'public-anon-key' },
region: FunctionRegion.UsEast1,
})
§Properties
§
region: FunctionRegion
[src]§Methods
§
invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionsResponse<T>>
[src]Invokes a function
@param functionName
- The name of the Function to invoke.
@param options
- Options for invoking the Function.
@example
const { data, error } = await functions.invoke('hello-world', {
body: { name: 'Ada' },
})