#I want to delete the user...
21 messages · Page 1 of 1 (latest)
You must do this server side with something like an Appwrite function that will also delete all their data.
Here's the method: https://appwrite.io/docs/references/cloud/server-nodejs/users#delete
for example using postman if we have the user id and we want to perform the delete req so can we do something like this?
Correct me if i am doing something wrong
If you need help seeing the http request, update the docs drop-down to show REST
i didn't understand
Go to the top of the page... There's a drop down for the language
You're asking about postman
i am saying that when i am hitting the api with the user id so this is not working
I don't understand. What is wrong exactly?
let me explain
i made a function to delete the user based on the user id
deleteIdentity: async () => {
try {
const response = await fetch("/api/deleteUser", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ userId: "662e530ca3c288d4e312" }),
});
console.log(response);
} catch (error) {
console.log("error in the delete identity function", error);
}
},
const deleteHandler = async () => {
try {
const res = await Store.deleteIdentity();
console.log(res);
} catch (error) {
console.log("error in the delete handler function", error);
}
};
<button onClick={deleteHandler}>
Delete Account
</button>
we are callin the function on the click of a button but it showing this error
And I what's your backend code for this?
there's no backend code
i just make a function and then calling it
import { Client, Account, Databases } from "appwrite";
export const API_ENDPOINT = import.meta.env.VITE_API_ENDPOINT;
export const PROJECT_ID = import.meta.env.VITE_PROJECT_ID;
export const DATABASE_ID = import.meta.env.VITE_DATABASE_ID;
export const COLLECTION_ID_MESSAGES = import.meta.env
.VITE_COLLECTION_ID_MESSAGES;
export const COLLECTION_ID_CHATBOX = import.meta.env.VITE_COLLECTION_ID_CHATBOX;
const client = new Client().setEndpoint(API_ENDPOINT).setProject(PROJECT_ID);
export const account = new Account(client);
export const databases = new Databases(client);
export default client;
this is the project setup
Then of course you'll get 404 since you didn't implement that api/deleteUser route...
is it only not working because of the route?