I'm trying to create a button in the user's profile(dashboard) page where a user can delete their account by themselves if they don't want to use the app.
But it's giving me this error.
Function for delete user:
const deleteUser = () => {
const promise = account.delete();
promise.then(
function (response) {
setUserDetails(response)
console.log(response);
router.push("/")
},
function (error) {
console.log(error);
window.location.reload()
}
)
}
Button to make the action happen:
<div className="mt-10 py-10 border-t border-gray-300 text-center">
<div className="flex flex-col flex-wrap justify-center items-center">
<button className='flex flex-row gap-1 px-4 py-2 bg-red-600 hover:bg-red-800 text-white'
onClick={() => {
deleteUser(userDetails.$id)
}}>
<MdDeleteForever className='text-lg mt-1' /> Delete Account
</button>
</div>
</div>
Kindly help me with this issue