adrianhajdin / social_media_app

Build a modern social app with a stunning UI with a native mobile feel, a special tech stack, an infinite scroll feature, and amazing performance using React JS, Appwrite, TypeScript, and more.
https://jsmastery.pro
1.07k stars 322 forks source link

missing required parameter file. #11

Closed MohammadHarish52 closed 8 months ago

MohammadHarish52 commented 8 months ago

`export async function createPost(post: INewPost) { try { //upload image to storage const uploadedFile = await uploadFile(post.file[0]);

if (!uploadedFile) {
  throw Error;
}
// Get file url
const fileUrl = getFilePreview(uploadedFile.$id);

if (!fileUrl) {
  deleteFile(uploadedFile.$id);
  throw Error;
}
// convert tags into an array
const tags = post.tags?.replace(/ /g, "").split(",") || [];

// save post to database
const newPost = await databases.createDocument(
  appwriteConfig.databaseId,
  appwriteConfig.postsCollectionId,
  ID.unique(),
  {
    creator: post.userId,
    caption: post.caption,
    location: post.location,
    imageUrl: fileUrl,
    imageId: uploadedFile?.$id,
    tags: tags,
  }
);
if (!newPost) {
  await deleteFile(uploadedFile?.$id);
  throw Error;
}
return newPost;

} catch (error) { console.log(error); }

}`

i am recieving this in error

MohammadHarish52 commented 8 months ago

Screenshot 2023-11-05 215140

MohammadHarish52 commented 8 months ago

fixed

aindriu80 commented 6 months ago

what was the fix?