Web Developer
Hi Guys,
Could someone please help with the below issue? I am keeping getting the following error, while creating a post and trying to save it on my Appwrite DB. User auth and creation works perfect, user is saved on the DB:
"api.ts:117
POST https://cloud.appwrite.io/v1/databases/65955c1f63e8af139596/collections/65955c743b49830747b8/documents 500 (Internal Server Error)
Error creating post document: AppwriteException: Server Error
at Client. (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=34b59556:850:17)
at Generator.next ()
at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=34b59556:488:24)"
my console.log (client side) is showing that the post has been created but is not getting saved to the DB.
Here are my code snippets - React+Vite:
1 - from PostForm.tsx
type PostFormProps = {
post?: Models.Document;
}
const PostForm = ({ post }: PostFormProps) => {
const { mutateAsync: createPost, isPending: isLoadingCreate } = useCreatePost();
const { user } = useUserContext();
const { toast } = useToast();
const navigate = useNavigate();
// 1. Define your form.
const form = useForm<z.infer>({
resolver: zodResolver(PostValidation),
defaultValues: {
caption: post ? post?.caption : "",
file: [],
location: post ? post?.location : "",
tags: post ? post.tags.join(",") : "",
},
})