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');
}
}