Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/transports/HTTPTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ type CredentialsOption = "omit" | "same-origin" | "include"
interface HTTPTransportOptions {
credentials?: CredentialsOption
headers?: Record<string, string>
fetch?: any
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what to put here (not a typescript guy...) but the linter didn't like Function

}

class HTTPTransport extends Transport {
public uri: string;
private readonly credentials?: CredentialsOption;
private readonly headers: Headers
private readonly headers: Headers;
private readonly fetch: any;
constructor(uri: string, options?: HTTPTransportOptions) {
super();
this.uri = uri;
this.credentials = options && options.credentials;
this.headers = HTTPTransport.setupHeaders(options && options.headers)
this.headers = HTTPTransport.setupHeaders(options && options.headers);
this.fetch = (options && options.fetch) || fetch;
}
public connect(): Promise<any> {
return Promise.resolve();
Expand All @@ -29,7 +32,7 @@ class HTTPTransport extends Transport {
const notifications = getNotifications(data);
const batch = getBatchRequests(data);
try {
const result = await fetch(this.uri, {
const result = await this.fetch(this.uri, {
method: "POST",
headers: this.headers,
body: JSON.stringify(this.parseData(data)),
Expand Down