#I want to delete the user...

21 messages · Page 1 of 1 (latest)

torn token
#

Actually we are building a chat application using react & Appwrite in the profile section we want to add a button that when the user click on it so it's account get deleted so is there any way to do it using the user id?

steel cypress
torn token
#

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

steel cypress
torn token
#

i didn't understand

steel cypress
torn token
#

ah oke let me check

#

i am working with react node js is already selected

steel cypress
torn token
#

i am saying that when i am hitting the api with the user id so this is not working

steel cypress
torn token
#

let me explain

torn token
#

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

steel cypress
torn token
#

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

steel cypress
#

Then of course you'll get 404 since you didn't implement that api/deleteUser route...

torn token
#

is it only not working because of the route?