Custom action calling supabase function stopped working

Database & APIs
//I have custom action :// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'dart:convert';
import 'package:supabase_flutter/supabase_flutter.dart';

Future<String> searchRecipes(String? searchPhrase) async {
  try {
    final supabase = SupaFlow.client;

    print('start');
    // Call the Supabase function using dynamic type
    dynamic response = await supabase.rpc(
      'search_recipes',
      params: {'search_phrase': searchPhrase},
    );
    print('Response raw data: ${response.toString()}');

    // Check if the response contains any data
    if (response == null) {
      print('No data returned from the search_recipes function');
      return jsonEncode([]);
    }

    print('end');
    // Handle the response
    print(jsonEncode(response));
    return jsonEncode(response);
  } catch (e, stackTrace) {
    print('Error occurred: $e\nStack trace: $stackTrace');
    return jsonEncode([]);
  }
}

which stopped working today suddenly. (worked fine today stopped working) I see this error in Console:

Error occurred: NoSuchMethodError: tried to call a non-function, such as null: 'T[_eval]'
Stack trace: packages/postgrest/src/postgrest_builder.dart.js 181:97             __t$PostgrestBuilderOfT$S$R
packages/postgrest/src/postgrest_builder.dart.js 513:30             new
packages/postgrest/src/postgrest_builder.dart.js 571:74             [_copyWithType]
packages/postgrest/src/postgrest_builder.dart.js 1123:88            rpc
packages/postgrest/src/postgrest_builder.dart.js 1248:95            rpc
packages/supabase/src/supabase_stream_builder.dart.js 1126:24       rpc
packages/recepty/backend/supabase/storage/storage.dart.js 30524:40  searchRecipes
dart:sdk_internal 48066:34                                          runBody
dart:sdk_internal 48102:7                                           _async
packages/recepty/backend/supabase/storage/storage.dart.js 30520:18  searchRecipes
packages/recepty/backend/supabase/storage/storage.dart.js 25915:69  <fn>
dart:sdk_internal 48066:34                                          runBody
dart:sdk_internal 48102:7                                           _async
packages/recepty/backend/supabase/storage/storage.dart.js 25913:82  <fn>
packages/flutter/src/scheduler/binding.dart.js 934:9                [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart.js 903:39               handleDrawFrame
packages/flutter/src/scheduler/binding.dart.js 812:12               [_handleDrawFrame]
dart:sdk_internal 207808:7                                          invoke
dart:sdk_internal 178890:15                                         invokeOnDrawFrame
dart:sdk_internal 207579:57                                         <fn>
dart:sdk_internal 69535:14                                          _callDartFunctionFast1
dart:sdk_internal 69473:22                                          ret

Any idea what is wrong? supabase function is working fine.

What have you tried so far?

I tried to get as much info about the error, also I have another action similar, stopped working too.

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