Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 :

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());
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading