Ak_2023
const submit = async (data) => { if (post) { const file = data.image[0] ? await appwriteService.uploadFile(data.image[0]) : null;
TypeScript
if (file) {
appwriteService.deleteFile(post.featuredImage);
}
const dbPost = await appwriteService.updatePost(post.$id, {
...data,
featuredImage: file ? file.$id : undefined,
});
if (dbPost) {
navigate(`/post/${dbPost.$id}`);
}
} else {
const file = await appwriteService.uploadFile(data.image[0]);
if (file) {
const fileId = file.$id;
data.featuredImage = fileId;
const dbPost = await appwriteService.createPost({ ...data, userId: userData.$id });
if (dbPost) {
navigate(`/post/${dbPost.$id}`);
}
}
}
};
TL;DR
Error in code due to trying to access property $id of undefined post. Need to ensure post is not undefined before accessing properties. Recommended threads
- Issue with Authentication
I am stuck with authentication using appwrite. I am getting bad request 400 error when trying to register though we already have project, database, collection c...
- JWT vs session (nodejs)
What is the difference between using JWT and the session secret? I thought you could validate the JWT without a request to the server, so I implemented it but r...
- LocalStorage fallback OAuth with Google ...
In https://appwrite.io/docs/advanced/platform/custom-domains When I check the localStorege, there is no data available for the account.