MCPcopy Index your code
hub / github.com/apitable/apitable / IsomorphicFetchHttpLibrary

Class IsomorphicFetchHttpLibrary

packages/api-client/http/isomorphic-fetch.ts:5–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import "whatwg-fetch";
4
5export class IsomorphicFetchHttpLibrary implements HttpLibrary {
6
7 public send(request: RequestContext): Observable<ResponseContext> {
8 let method = request.getHttpMethod().toString();
9 let body = request.getBody();
10
11 const resultPromise = fetch(request.getUrl(), {
12 method: method,
13 body: body as any,
14 headers: request.getHeaders(),
15 credentials: "same-origin"
16 }).then((resp: any) => {
17 const headers: { [name: string]: string } = {};
18 resp.headers.forEach((value: string, name: string) => {
19 headers[name] = value;
20 });
21
22 const body = {
23 text: () => resp.text(),
24 binary: () => resp.blob()
25 };
26 return new ResponseContext(resp.status, headers, body);
27 });
28
29 return from<Promise<ResponseContext>>(resultPromise);
30
31 }
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected