Skip to content

Commit 218fc29

Browse files
committed
feat: add ability to pass headers in callApi function
1 parent 1c92c17 commit 218fc29

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adminforth/spa/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ const LS_LANG_KEY = `afLanguage`;
1313
const MAX_CONSECUTIVE_EMPTY_RESULTS = 2;
1414
const ITEMS_PER_PAGE_LIMIT = 100;
1515

16-
export async function callApi({path, method, body=undefined}: {
16+
export async function callApi({path, method, body, headers}: {
1717
path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
1818
body?: any
19+
headers?: Record<string, string>
1920
}): Promise<any> {
2021
const options = {
2122
method,
2223
headers: {
2324
'Content-Type': 'application/json',
2425
'accept-language': localStorage.getItem(LS_LANG_KEY) || 'en',
26+
...headers
2527
},
2628
body: JSON.stringify(body),
2729
};

0 commit comments

Comments
 (0)