flutterflutter-dependenciesflutter-web

Supabase return invalid json in response Flutter


I m new in Supabase when I try to fetch my table data so the return in response is invalid JSON. how to convert it ?

Supabase calling method code is:

try {
  var response = await SupabaseCredentials.supabaseClient
      .from("emp_table")
      .select();
  print("response.data");
  print(response);
} catch (e) {
  print(e.toString());
}

}

Returning response is:

[{id: 1, created_at: 2023-01-12T10:59:08.631522+00:00, emp_designation: Technical, emp_username: fzn, emp_contact: +91989274, emp_email: m.developer0@gmail.com, emp_address: Uttar Pradesh.}]

This response is an invalid JSON


Solution

  • Used jsonEncode(RESPONSE); Before converting your object in JSON use import 'dart:convert';

    Example:

    try {
      var response = await SupabaseCredentials.supabaseClient
          .from("emp_table")
          .select();
      print("response.data");
      print(jsonEncode(response));
    } catch (e) {
      print(e.toString());
    }