Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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 region: FunctionRegion;
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 }?: {
headers?: Record<string, string>;
customFetch?: Fetch;
region?: FunctionRegion;
}
)
[src]

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

§
fetch: Fetch
[src]
§
headers: Record<string, string>
[src]
§
url: string
[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' },
})
§
setAuth(token: string): void
[src]

Updates the authorization header

@param token
  • the new jwt token sent in the authorisation header
@example
functions.setAuth(session.access_token)