Invokes a Supabase Edge Function.
Invokes a function
Invoke a Supabase Edge Function.
- Requires an Authorization header.
- Invoke params generally match the Fetch API spec.
- When you pass in a body to your function, we automatically attach the Content-Type header for
Blob
,ArrayBuffer
,File
,FormData
andString
. If it doesn't match any of these types we assume the payload isjson
, serialize it and attach theContent-Type
header asapplication/json
. You can override this behavior by passing in aContent-Type
header of your own. - Responses are automatically parsed as
json
,blob
andform-data
depending on theContent-Type
header sent by your function. Responses are parsed astext
by default.
Parameters
functionName
REQUIRED
stringThe name of the Function to invoke.
options
Optional
FunctionInvokeOptionsOptions for invoking the Function.
body
Optional
objectThe body of the request.
headers
Optional
objectObject representing the headers to send with the request.
method
Optional
"POST" | "GET" | "PUT" | "PATCH" | "DELETE"The HTTP verb of the request
region
Optional
FunctionRegionThe Region to invoke the function in.
UsWest2
Optional
"us-west-2"UsWest1
Optional
"us-west-1"UsEast1
Optional
"us-east-1"SaEast1
Optional
"sa-east-1"EuWest3
Optional
"eu-west-3"EuWest2
Optional
"eu-west-2"EuWest1
Optional
"eu-west-1"EuCentral1
Optional
"eu-central-1"CaCentral1
Optional
"ca-central-1"ApSoutheast2
Optional
"ap-southeast-2"ApSoutheast1
Optional
"ap-southeast-1"ApSouth1
Optional
"ap-south-1"ApNortheast2
Optional
"ap-northeast-2"ApNortheast1
Optional
"ap-northeast-1"Any
Optional
"any"
const { data, error } = await supabase.functions.invoke('hello', {
body: { foo: 'bar' }
})