refactoring magic strings: User API URLs in user-management view
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import { API_ROUTES } from '../../index.js';
|
||||
|
||||
const { data } = $props();
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
});
|
||||
|
||||
async function getUsers() {
|
||||
const URL = '/api/users';
|
||||
const URL = API_ROUTES.USERS;
|
||||
|
||||
try {
|
||||
const response = await fetch(URL);
|
||||
@@ -42,7 +43,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const URL = '/api/users';
|
||||
const URL = API_ROUTES.USERS;
|
||||
const userData = { userName: userName, userPassword: userPassword };
|
||||
|
||||
try {
|
||||
@@ -78,7 +79,7 @@
|
||||
}
|
||||
|
||||
async function deleteUser(userId: string) {
|
||||
const URL = `/api/users/${userId}`;
|
||||
const URL = API_ROUTES.USER(userId);
|
||||
|
||||
try {
|
||||
const response = await fetch(URL, {
|
||||
|
||||
Reference in New Issue
Block a user