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.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);
}
When you run account.get you're getting back account model instance
https://appwrite.io/docs/models/account
now it works, thanks
i see
Great
[SOLVED ]Can`t get an userId
Recommended threads
- Errore 403
Ho errore 403 ma il package name è corretto
- Cannot create sites using Flutter framew...
Cannot goto next step, it shows error "missing buildRuntime". I need to select "other" framework then deploys fail, go back to site settings and change "other" ...
- Appwrite mariadb container suddenly usin...
I'm hosting an instance of appwrite since months and updated to 1.8.0 couple of weeks ago. Everything worked fine, but today I noticed that my server is lagging...