Updates
This commit is contained in:
@@ -19,6 +19,7 @@ export default async function clientCrudFetch<
|
||||
targetId,
|
||||
method = "GET",
|
||||
apiOrigin,
|
||||
headers,
|
||||
}: ClientCrudFetchParams<T, P>) {
|
||||
try {
|
||||
let pathname = basePath || ``;
|
||||
@@ -43,6 +44,7 @@ export default async function clientCrudFetch<
|
||||
>(pathname, {
|
||||
method,
|
||||
body,
|
||||
headers,
|
||||
});
|
||||
|
||||
return res;
|
||||
|
||||
+4
-12
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user