export type GetApiUsersArgs = {names?: string | undefined}; export type GetApiUsersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all users * * GET /users */ export const getApiUsers = async (args: GetApiUsersArgs, options?: GetApiUsersOptions) => { const {baseUrl = "http://localhost:8081/ims-users/resources", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.names != null) query.append("names", String(args.names)) const url = `${baseUrl.replace(/\/+$/, '')}/users${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };