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
, serialise it and attach theContent-Type
header asapplication/json
. You can override this behaviour 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
const { data, error } = await supabase.functions.invoke('hello', {
body: { foo: 'bar' }
})