In this part, we will change how the component works with the new functions. Follow these instructions to change it correctly:
- Open the App.vue file inside the src folder.
- In the getAllUsers method, we will need to change the way the response is defined because axios gives us a completely different response object than the Fetch API:
async getAllUsers() {
const { data } = await getHttp(`${window.location.href}api/users`);
this.response = data;
},
- In the deleteUser method, we can just pass the URL as the parameter:
async deleteUser(id) {
await deleteHttp(`${window.location.href}api/users/${id}`);
await this.getAllUsers();
},
To run the server and see your component, you need to open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> npm run serve