From 218fc29ea6ac59a5faa63eb597e4314c034ec4fa Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Tue, 14 Oct 2025 15:13:43 +0300 Subject: [PATCH] feat: add ability to pass headers in callApi function --- adminforth/spa/src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adminforth/spa/src/utils.ts b/adminforth/spa/src/utils.ts index eef5bf86..c38ac361 100644 --- a/adminforth/spa/src/utils.ts +++ b/adminforth/spa/src/utils.ts @@ -13,15 +13,17 @@ const LS_LANG_KEY = `afLanguage`; const MAX_CONSECUTIVE_EMPTY_RESULTS = 2; const ITEMS_PER_PAGE_LIMIT = 100; -export async function callApi({path, method, body=undefined}: { +export async function callApi({path, method, body, headers}: { path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' body?: any + headers?: Record }): Promise { const options = { method, headers: { 'Content-Type': 'application/json', 'accept-language': localStorage.getItem(LS_LANG_KEY) || 'en', + ...headers }, body: JSON.stringify(body), };