Deleting a user

I’m making a app so I want the admin to have the options to create a user and delete a user. The create user part is done but how do I delete a user??
I’m using rest api(php).

Make a call to the api endpoint that deletes the user

That’s it?? I mean no need to write any code from front end side.

Well you haven’t really given any information, but given that you’re using an API to hold the source of truth of information that exists, the deletion of the user needs to happen there. The front end code is all UI, so you’ll probably want to give some feedback when it’s complete or output any errors. Probably distinguish an admin from a non-admin so you only show the delete-user UI to an admin (though that should still be verified on the api side before any actions are taken). But ultimately, to delete the user you just need to call the api endpoint that handles that action.


Well thanks Beck24, I’ll try and let you know! :sunglasses:

So I tried what you said but I got stuck in one place i.e I load the User Id from the database(rest api) and then I used ion check box to select the user whom i want to delete but as I have all the users param same i.e uid, when I use ngmodel to get the value of the selected item all the items are selected just because of “uid”. So how can i select only one user and get the uid value??
below is my code:


    <ion-title>Delete User</ion-title>


<ion-content padding>
  <div *ngFor="let obj of response1Obj; let i = index">
      <ion-label>User ID: {{obj.uid}}</ion-label>
      <ion-checkbox [(ngModel)]="uid" color="Royal"></ion-checkbox>
    <button ion-button (click)="delUser();" style="text-align:center;">Delete</button>


    <ion-item *ngFor="let user of users">
        <ion-checkbox item-start [(ngModel)]="user.selected"></ion-checkbox>

<button ion-button block (click)="deleteUsers()">Delete selected users</button>


public users: any[] = [{
        id: 1,
        name: 'John',
        selected: false
        id: 2,
        name: 'Marie',
        selected: false
        id: 3,
        name: 'Jack',
        selected: false
        id: 4,
        name: 'Steven',
        selected: false
        id: 5,
        name: 'David',
        selected: false
    deleteUsers() {
        let userIdsToRemove: number[] = [];
        this.users.forEach((user) => {
            if (user['selected']) userIdsToRemove.push(user['id'])
        console.log(userIdsToRemove.length ? userIdsToRemove : 'There is no users selected!');

Thanks for your reply Ramon but I can’t give id’s to each user as I’m fetching it from an rest api and displaying it and at the same moment trying to select and delete a user.

REST API must give you an unique identifier for each user.

That’s the work of back end right!!