diff --git a/packages/http/src/FetchHttpClient.ts b/packages/http/src/FetchHttpClient.ts index e07f2010..2af4973f 100644 --- a/packages/http/src/FetchHttpClient.ts +++ b/packages/http/src/FetchHttpClient.ts @@ -3,7 +3,7 @@ import HttpClient from './interfaces/HttpClient'; export default class FetchHttpClient implements HttpClient { - async execute(url: string, options: object): Promise + async execute(url: string, options?: RequestInit): Promise { return fetch(url, options); } diff --git a/packages/http/src/HttpRemoteBuilder.ts b/packages/http/src/HttpRemoteBuilder.ts index 350254e5..aed6f931 100644 --- a/packages/http/src/HttpRemoteBuilder.ts +++ b/packages/http/src/HttpRemoteBuilder.ts @@ -9,9 +9,9 @@ export default class HttpRemoteBuilder implements RemoteBuilder { readonly #httpClient: HttpClient; - constructor() + constructor(httpClient: HttpClient = new FetchHttpClient()) { - this.#httpClient = new FetchHttpClient(); + this.#httpClient = httpClient; } build(url: string): Remote diff --git a/packages/http/src/interfaces/HttpClient.ts b/packages/http/src/interfaces/HttpClient.ts index 431f3cbe..480ab324 100644 --- a/packages/http/src/interfaces/HttpClient.ts +++ b/packages/http/src/interfaces/HttpClient.ts @@ -1,7 +1,7 @@ interface HttpClient { - execute(url: string, options: object): Promise; + execute(url: string, options?: RequestInit): Promise; } export default HttpClient;