Home > Back-end >  How to fetch data from supabase
How to fetch data from supabase

Time:01-20

I tried this by exploring web and supabase docs but nothing really happens

import 'package:supabase/supabase.dart';

class supahandelar {
  static const SupaUrl = 'UrlFromSupabase';
  static const SupaKey = 'KeyFromSupabase';

  final client = SupabaseClient(SupaUrl, SupaKey);
  getData() async {
    var response = await client.from('Pokemons').select().execute();
    print("Respnse");
    print(response);
    
  }
}

It gives me this output on console:

instance of 'minified:hy<erased>'

Also not getting any output in widgets/ui

Can anyone please suggest me simple methods to only fetch data.

CodePudding user response:

Here are a few things you could try to troubleshoot the issue:

  • Make sure that the SupaUrl and SupaKey variables are correctly set to the URL and key of your Supabase project.

  • Try printing out the client object to see if it's being initialized
    correctly.

  • Make sure that you have the supabase package installed and imported
    correctly in your Dart code.

  • Make sure that the table name "Pokemons" is present in your Supabase project.

  • To get more readable information on what's going on, use:

    flutter run -d chrome --profile --verbose

CodePudding user response:

It was just an RSL issues. When i tried with new databases without RSL disabled it worked.

So i need to create RSL Policy of who to allow read data... For Ex:-I Added true for all user to read

If anyone face this issue please check/ Create RSL Policy.

  • Related