File tree 1 file changed +7
-5
lines changed
sdk-template-overrides/typescript/http
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { HttpLibrary, RequestContext, ResponseContext} from './http{ {extensionForDeno} }';
2
2
import { from, Observable } from { {#useRxJS} }'rxjs'{ {/useRxJS} }{ {^useRxJS} }'../rxjsStub{ {extensionForDeno} }'{ {/useRxJS} };
3
- import createFetch, { FetchModule } from '@fortaine/fetch';
3
+ import createFetch, { RequestInfo, RequestInit } from '@fortaine/fetch';
4
4
{ {#platforms} }
5
5
{ {#browser} }
6
6
import "whatwg-fetch";
7
7
{ {/browser} }
8
8
{ {/platforms} }
9
9
10
- { {! https://github.com/ajaishankar/openapi-typescript-fetch #server-side-usage } }
11
- globalThis.fetch = createFetch(fetch as unknown as FetchModule) as any;
12
-
13
10
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
11
+ static fetch (...args: [RequestInfo, RequestInit]) {
12
+ const fetcher = {{#platforms} }{ {#node} }(createFetch as any)(){ {/node} }{ {^node} }fetch{ {/node} }{ {/platforms} };
13
+
14
+ return fetcher(...args);
15
+ }
14
16
15
17
public send(request: RequestContext): Observable<ResponseContext > {
16
18
let method = request.getHttpMethod().toString();
17
19
let body = request.getBody();
18
20
19
- const resultPromise = fetch (request.getUrl(), {
21
+ const resultPromise = IsomorphicFetchHttpLibrary. fetch (request.getUrl(), {
20
22
method: method,
21
23
body: body as any,
22
24
headers: request.getHeaders(),
You can’t perform that action at this time.
0 commit comments