list users
This commit is contained in:
27
frontend/lib/api/admin/listUsers.ts
Normal file
27
frontend/lib/api/admin/listUsers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ApiResponse } from '~/shared/types/api';
|
||||
import type { AuthUser } from '~/shared/types/auth';
|
||||
import { getApiHeaders } from '..';
|
||||
|
||||
export async function listUsers(): Promise<
|
||||
{ success: true; users: AuthUser[] } | { success: false }
|
||||
> {
|
||||
const { data } = await useFetch<ApiResponse<AuthUser[]>>(
|
||||
getApiUrl('admin/users'),
|
||||
{
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
responseType: 'json',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
users: data.value.data,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user