mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
29 lines
792 B
TypeScript
29 lines
792 B
TypeScript
"use server";
|
|
|
|
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
|
import { handleApiError, handleApiResponse } from "@/lib/server-actions-helper";
|
|
|
|
const RECIPIENTS_PATH = "/alerts/recipients";
|
|
|
|
export const listAlertRecipients = async (
|
|
searchParams?: Record<string, string | undefined>,
|
|
) => {
|
|
const headers = await getAuthHeaders({ contentType: false });
|
|
const url = new URL(`${apiBaseUrl}${RECIPIENTS_PATH}`);
|
|
|
|
if (searchParams) {
|
|
for (const [key, value] of Object.entries(searchParams)) {
|
|
if (value !== undefined && value !== "") {
|
|
url.searchParams.append(key, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(url.toString(), { headers });
|
|
return handleApiResponse(response);
|
|
} catch (error) {
|
|
return handleApiError(error);
|
|
}
|
|
};
|