Hi, I'm using Appwrite Auth in my iOS app. While signing up, I fetch the user's full name and pass it into the account.create() function as such:
await account.create(ID.unique(), email, password, name);
Inside my app, I want to display greetings like Good morning, {firstName}
But when I try that with this code:
const [firstName, setFirstName] = useState("");
useEffect(() => {
const getUserData = async () => {
try {
const userData = await account.get();
if (userData && userData.name) {
// Split the name and get the first part
const firstNameOnly = userData.name.split(' ')[0];
setFirstName(firstNameOnly || "User");
} else {
setFirstName("User");
}
} catch (error) {
console.error("Error fetching user data:", error);
setFirstName("User"); // Fallback name if there's an error
}
};
getUserData();
}, []);
I always see "User", yet appwrite cloud shows the full name, separated by whitespaces, as it should be.
Also, inside the settings of my app, I want the user to be able to edit their full name so that if they want to use a nickname they can do so. I didn't find any functions that can edit the name of an user - is there any way to do this ?
I'm on expo (react native).
i tried console.log-ing await account.get().name in many ways but it is always either empty string or the default value set by typescript
should probably be -
(await account.get()).name
or if you console log the whole user object, whats the output?
console.log(JSON.stringify(userData, null, 2))
oh yay your console log statement helped me debug this ! thanks a lot.
I was in the wrong account which was created before I started passing the name in the account.create() function, so it had a null name.
[RESOLVED] Appwrite Auth can't resolve user's name
Recommended threads
- Quota not resetting
hi, im using appwrite's free tier plani hit my read limts last month and the billing cycle said it would reset on june 4th but that is today, the billing cycle ...
- Student plan issue
I am using GitHub student plan, I even got access to appwrite's mock phone number. but when I try to use it, it says the phone number limit has reached
- DB Relational Table Request
Hi, I'd like to suggest a rewording of the relationships between tables. - Current wording: storeOperatingDays can contain one storeId ...