Invokes a Supabase Function. See the guide for details on writing Functions.
The name of the function to invoke.
Custom headers to send with the request.
The body of the request.
HTTP method of the request. Defaults to POST.
Cancels the in-flight request when the provided `Future` completes. It must not complete with an error. On abort, an `http.RequestAbortedException` (from `package:http`) is thrown. Useful for cancelling a request in response to an event or for setting a request timeout.
final res = await supabase.functions.invoke('hello', body: {'foo': 'baa'});
final data = res.data;
final res = await supabase.functions.invoke(
'hello',
body: {'foo': 'baa'},
headers: {
'Authorization': 'Bearer ${supabase.auth.currentSession?.accessToken}'
},
);
import 'package:http/http.dart' as http;
try {
final res = await supabase.functions.invoke(
'hello',
body: {'foo': 'baa'},
abortSignal: Future.delayed(const Duration(seconds: 5)),
);
final data = res.data;
} on http.RequestAbortedException catch (error) {
print('Request was aborted: $error');
}