Back

[SOLVED ]Can`t get an userId

  • 0
  • Flutter
Chewbacca
2 Apr, 2023, 17:39

Hi guys, I tried to user account.get(), but I got Instance of "Account" instead of userId.

TypeScript
      final document = databases.createDocument(
          databaseId: '---',
          collectionId: '---',
          documentId: ID.unique(),
          data: {
            "userid": "$res",
            "name": "test1",
            "mileage": "test2",
            "date":
                "${_selectedDate.day}-${_selectedDate.month}-${_selectedDate.year}",
          });
    }```
TL;DR
User was not able to get the userId when using the `account.get()` method. They were getting an instance of "Account" instead. The solution was provided to print the user ID using the following code: ```dart try{ final account = await account.get(); print(account.$id); } catch(e){ print(e); } ``` Additionally, there was a separate issue mentioned where the user was creating a document in a database but not retrieving the userId. No solution was provided for this issue.
Binyamin
2 Apr, 2023, 17:41

When you run and print the user ID what you get?

TypeScript
try{
  final account = await account.get();
  print(account.$id);
} catch(e){
 print(e);
}
Binyamin
2 Apr, 2023, 17:47

When you run account.get you're getting back account model instance https://appwrite.io/docs/models/account

Chewbacca
2 Apr, 2023, 17:47

now it works, thanks

Chewbacca
2 Apr, 2023, 17:47

i see

Binyamin
2 Apr, 2023, 17:47

Great

Chewbacca
2 Apr, 2023, 17:49

[SOLVED ]Can`t get an userId

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more