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
- I have an error oauth with Microsoft
invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for...
- how many Teams can be created?
I am creating an app where I will let users create groups. This could mean there will be many groups created by user, to isolate those groups properly I am thin...
- React native app login via Safari
Hi! I deployed for debug my React Native app in web, chrome everythink works well but in safari on mac and ios I cant login. I found this one error in safari co...
