Web Developer
async createProfile({ email, name, userid, profilephoto, rating = 0, level }) {
try {
// console.log(email)
const session = await this.databases.createDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
ID.unique(),
{
userid,
profilephoto,
rating,
level,
name,
email,
}
)
return session
} catch (err) {
console.log("error at createProfile", err)
}
}
async updateProfile(id, { email, name, profilephoto, rating, level }) {
try {
// console.log(userid);
return await this.databases.updateDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
id,
{
profilephoto,
rating,
level,
name,
email,
}
)
} catch (err) {
console.log("error at updateProfile", err)
}
} This is code to create and update document. Getting cors error:Access to fetch at 'https://cloud.appwrite.io/v1/databases/66921baf003454626d41/collections/66921bba002560aefc33/documents/66928c3e003018c200da' from origin 'http://localhost:5173' has been blocked by CORS policy: Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response.Understand this error
client.ts:429
PATCH https://cloud.appwrite.io/v1/databases/66921baf003454626d41/collections/66921bba002560aefc33/documents/66928c3e003018c200da net::ERR_FAILED