Junaid Khalid
Junaid Khalid

Reputation: 941

Cannot upload data to database in supabase

I am using Flutter and learning Supabase. It is now getting frustrating as there is no response or exception mechanism. I am using the following code, Note: The user is being signed up and signed in successfully, and the auth policy of the users table is also set to public but nothing in logs and no exception is being caught as well

try {
        _user = UserModel(id: authResponse.user!.id, name: name, email: email);
        final response = await _supabase.from("users").insert(_user!.toJson());
        log(response.toString());
        log(_user!.toJson());
      } catch (e) {
        log(e.toString());
        return false;
      }

Upvotes: 0

Views: 42

Answers (1)

Junaid Khalid
Junaid Khalid

Reputation: 941

I had to hardcode the map a bit to solve the problem

try {
        _user = UserModel(id: authResponse.user!.id, name: name, email: email);
        final response = await _supabase.from("users").insert({
          "id": _user!.id,
          "email": _user!.email,
          "name": _user!.name
        }).select();
        log(response.toString());
        log(_user!.toJson());
      } catch (e) {
        log(e.toString());
        return false;
      }

Upvotes: 0

Related Questions