diff --git a/src/Utils/request/query.ts b/src/Utils/request/query.ts
index 3431f625728..c198de5fea5 100644
--- a/src/Utils/request/query.ts
+++ b/src/Utils/request/query.ts
@@ -5,15 +5,26 @@ import { getResponseBody } from "@/Utils/request/request";
import { QueryOptions, Route } from "@/Utils/request/types";
import { makeHeaders, makeUrl } from "@/Utils/request/utils";
+// Extend the QueryOptions interface to include customHeaders
+export interface ExtendedQueryOptions
extends QueryOptions {
+ customHeaders?: Record;
+}
+
async function queryRequest(
{ path, method, noAuth }: Route,
- options?: QueryOptions,
+ options?: ExtendedQueryOptions,
): Promise {
const url = `${careConfig.apiUrl}${makeUrl(path, options?.queryParams, options?.pathParams)}`;
+ // Merge customHeaders with default headers
+ const headers = {
+ ...makeHeaders(noAuth ?? false),
+ ...(options?.customHeaders || {}),
+ };
+
const fetchOptions: RequestInit = {
method,
- headers: makeHeaders(noAuth ?? false),
+ headers,
signal: options?.signal,
};
@@ -48,7 +59,7 @@ async function queryRequest(
*/
export default function query(
route: Route,
- options?: QueryOptions,
+ options?: ExtendedQueryOptions,
) {
return ({ signal }: { signal: AbortSignal }) => {
return queryRequest(route, { ...options, signal });