Back
Type 'URL' is missing the following properties from type 'Url': auth, path, slashes, query
- 0
- Web

The code is as below
TypeScript
import { ID } from "appwrite";
import { account, appwriteConfig, avatars, databases } from "./config";
import { Url } from "url";
export async function createUserAccount(user: INewUser) {
try {
const newAccount = await account.create(
ID.unique(),
user.email,
user.password,
user.name
);
if (!newAccount) throw Error;
const avatarUrl = avatars.getInitials(user.name);
const newUser = await saveUserToDB({
accountId: newAccount.$id,
name: newAccount.name,
email: newAccount.email,
username: user.username,
imageUrl: avatarUrl, // THE ERROR POPS UP HERE
});
return newUser;
} catch (error) {
console.log(error);
return error;
}
}
export async function saveUserToDB(user: {
user: string;
email: string;
name: string;
imageUrl: Url;
username?: string;
}) {
try {
const newUser = await databases.createDocument(
appwriteConfig.databaseId,
appwriteConfig.userCollectionId,
ID.unique(),
user
);
return newUser;
} catch (error) {
console.log(error);
}
}```
The error pops up when assigning imageUrl property to avatarUrl as shown in the pic.
The error as shown in the pic states states "Type 'URL' is missing the following properties from type 'Url': auth, path, slashes, queryts(2739) api.ts(45, 3): The expected type comes from property 'imageUrl' which is declared here on type '{ user: string; email: string; name: string; imageUrl: Url; username?: string | undefined; }' "
Both avatarUrl and imageUrl are of type url. But i am not able to add avatarUrl as imageUrl's property. How can i rectify this error ?
TL;DR
The developers are encountering an error when assigning `avatarUrl` as the `imageUrl` property due to a mismatch in the types. The issue arises from using 'Url' instead of 'URL'. By correcting the capitalization to 'URL' in the code, the error should be resolved.Recommended threads
- Google sign in wont allow you to choose ...
Hi, this is still unsolved, Appwrite's SDK won't let you specify prompt=select_account param, so a user cannot signin with a desired account, in chrome is just ...
- Console ErrorAppwriteException: User (ro...
AppwriteException: User (role: guests) missing scope (account) at Client.eval (webpack-internal:///(app-pages-browser)/./node_modules/appwrite/dist/esm/sdk....
- AppwriteException: Project ID not found
I'm getting this error: `Error signing up: AppwriteException: Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project...
