Invoke a function
Invokes a function
Invoke a Supabase 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
- functionNameREQUIREDstring
The name of the Function to invoke.
- optionsOptionalFunctionInvokeOptions
Options for invoking the Function.
bodyOptionalobjectThe body of the request.
headersOptionalobjectObject representing the headers to send with the request.
methodOptional"POST" | "GET" | "PUT" | "PATCH" | "DELETE"The HTTP verb of the request
const { data, error } = await supabase.functions.invoke('hello', {
body: { foo: 'bar' }
})