import { fetchIt } from './imports'; import { getEndpoint } from './endpoint_utils'; /** * Makes a secure fetch through your API gateway. */ export async function secureFetchIt( endpoint: any, body: any = null, method: any = null, headers: Record | null = null, blob: boolean = false, noApi: boolean = true, withCredentials: boolean = true, returnJson: boolean = true, returnResult: boolean = true ): Promise { const url = await getEndpoint(endpoint); // fetchIt returns either JSON or Blob based on args, // but we unify to T here. const result = await fetchIt( url, body, method, headers, blob, noApi, withCredentials, returnJson, returnResult ); return result as T; }