Invokes a function
The name of the Function to invoke.
Options for invoking the Function.
const { data, error } = await functions.invoke('hello-world', {
body: { name: 'Ada' },
})
const { data, error } = await supabase.functions.invoke('hello', {
body: { foo: 'bar' }
})
import { FunctionsHttpError, FunctionsRelayError, FunctionsFetchError } from "@supabase/supabase-js";
const { data, error } = await supabase.functions.invoke('hello', {
headers: {
"my-custom-header": 'my-custom-header-value'
},
body: { foo: 'bar' }
})
if (error instanceof FunctionsHttpError) {
const errorMessage = await error.context.json()
console.error('Function returned an error', errorMessage)
} else if (error instanceof FunctionsRelayError) {
console.error('Relay error:', error)
} else if (error instanceof FunctionsFetchError) {
console.error('Fetch error:', error)
}
const { data, error } = await supabase.functions.invoke('hello', {
headers: {
"my-custom-header": 'my-custom-header-value'
},
body: { foo: 'bar' }
})
const { data, error } = await supabase.functions.invoke('hello', {
headers: {
"my-custom-header": 'my-custom-header-value'
},
body: { foo: 'bar' },
method: 'DELETE'
})
import { createClient, FunctionRegion } from '@supabase/supabase-js'
const { data, error } = await supabase.functions.invoke('hello', {
body: { foo: 'bar' },
region: FunctionRegion.UsEast1
})
const { data, error } = await supabase.functions.invoke('hello', {
headers: {
"my-custom-header": 'my-custom-header-value'
},
method: 'GET'
})
const { data, error } = await functions.invoke('hello-world', {
body: { name: 'Ada' },
})