Invoke supabase edge functions

Custom Code

I have an edge functions that works perfectly fine with an API post call

I want to invoke the edge function with a custom action but I am having an error( look image attached)

Here is the code i ve been trying:

import 'package:http/http.dart' as http;

import 'dart:convert';

Future<void> sendPasswordResetEmail(String email) async {

final url = 'my edge function UrL';

final headers = {

'Content-Type': 'application/json',

'Authorization': 'Bearer ANON_Key',

};

final body = jsonEncode({

"email": email,

});

print('Request body: $body');

try {

final response = await http.post(

Uri.parse(url),

headers: headers,

body: body,

);

print('Response status code: ${response.statusCode}');

print('Response body: ${response.body}');

if (response.statusCode == 200) {

print('Password reset email sent successfully');

} else {

print('Error sending password reset email. Status code: ${response.statusCode}');

print('Error body: ${response.body}');

}

} catch (error) {

print('Exception occurred while sending password reset email: $error');

}

}

What have you tried so far?

i tested supabase instance call

import 'package:supabase_flutter/supabase_flutter.dart';

Future<void> initializeSupabase() async {

await Supabase.initialize(

url: 'YOUR_PROJECT_URL',

anonKey: 'YOUR_ANON_KEY',

);

}

Future<void> sendPasswordResetEmail(String email) async {

final supabase = Supabase.instance.client;

final response = await supabase.functions.invoke(

'reset-password-email',

body: {'email': email},

);

if (response.status == 200) {

final data = response.data;

print('Response data: $data');

} else {

print('Error: ${response.error?.message}');

}

}

Did you check FlutterFlow's Documentation for this topic?
No
2 replies