Home > OS >  Supabase return invalid json in response Flutter
Supabase return invalid json in response Flutter

Time:01-13

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: [email protected], emp_address: Uttar Pradesh.}]

This response is an invalid JSON

CodePudding user response:

Bro just used jsonEncode(YOUR_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());
}
  • Related