1

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

  • try to create a model class, check [this example](https://github.com/yeasin50/Flutter-project-Helper/blob/master/jsonFormating/sample1.dart) – Md. Yeasin Sheikh Jan 12 '23 at 11:38

1 Answers1

1

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());
}
Mohammad Faizan
  • 191
  • 1
  • 4