MCPcopy Create free account
hub / github.com/apitable/apitable / fetchInterceptor

Function fetchInterceptor

packages/core/src/modules/database/api/wasm/index.ts:83–104  ·  view source on GitHub ↗
(fetch: () => Promise<any>)

Source from the content-addressed store, hash-verified

81}
82
83async function fetchInterceptor<T>(fetch: () => Promise<any>): Promise<AxiosResponse<IApiWrapper & { data: T }>> {
84 let respData: IApiWrapper & { data: T };
85 try {
86 if (!isInitialized()) {
87 await initializeDatabusWasm();
88 }
89 respData = await fetch();
90 } catch (e) {
91 console.error(e);
92 respData = {} as IAxiosResponse<T>['data'];
93 throw new Error('fetch failure for wasm');
94 }
95
96 if (isClient() && window.__global_handle_response) {
97 return window.__global_handle_response({
98 data: respData,
99 }, undefined, undefined);
100 }
101 return {
102 data: respData
103 } as unknown as AxiosResponse<IApiWrapper & { data: T }>;
104}
105
106const initializeDatabusWasm = async () => {
107 if (!isClient()) {

Callers 1

getFunction · 0.85

Calls 5

isClientFunction · 0.90
isInitializedFunction · 0.85
initializeDatabusWasmFunction · 0.85
fetchFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected