This commit is contained in:
2025-12-26 12:08:45 +01:00
parent f95cf21ffd
commit 5caa604b8f
9 changed files with 20 additions and 36 deletions
+4 -12
View File
@@ -1,4 +1,5 @@
import _ from "lodash";
import { DSQLClientFetchHeader } from "../../package-shared/types";
type FetchApiOptions<T extends { [k: string]: any } = { [k: string]: any }> = {
method:
@@ -13,11 +14,7 @@ type FetchApiOptions<T extends { [k: string]: any } = { [k: string]: any }> = {
| "put"
| "patch";
body?: T | string;
headers?: FetchHeader;
};
type FetchHeader = HeadersInit & {
[key: string]: string | null;
headers?: DSQLClientFetchHeader;
};
export type FetchApiReturn = {
@@ -40,12 +37,7 @@ export default async function fetchApi<
/**
* Key to use to grab local Storage csrf value.
*/
localStorageCSRFKey?: string,
/**
* Key with which to set the request header csrf
* value
*/
csrfHeaderKey?: string
localStorageCSRFKey?: string
): Promise<R> {
let data;
@@ -54,7 +46,7 @@ export default async function fetchApi<
let finalHeaders = {
"Content-Type": "application/json",
} as FetchHeader;
} as DSQLClientFetchHeader;
if (csrf && csrfValue) {
finalHeaders[localStorageCSRFKey || csrfKey] = csrfValue;