fucking DELETE method for account is now working and existing

This commit is contained in:
cherif
2023-01-17 15:57:43 +01:00
parent 44f9f8e21b
commit c2812c0534
4 changed files with 32 additions and 7 deletions

View File

@@ -108,6 +108,23 @@
avatar = await fetchAvatar(user.username);
}
const deleteAccount = async() => {
console.log("deleting account")
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`, {
method: "DELETE",
})
.then((response) => {
if (!response.ok) {
throw new Error("HTTP " + response.status);
}
console.log("account deleted")
push('/');
})
.catch((error) => {
console.log("catch unable to delete: ", error);
});
}
</script>
@@ -152,6 +169,7 @@
</form>
</Card>
</div>
<Button type="primary" on:click={() => deleteAccount()}>Delete Account</Button>
</div>
</main>