Skip to content

Commit b3ed21d

Browse files
committed
add more documentation for kiotaClientFactory usage
1 parent 9f858ac commit b3ed21d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

packages/http/fetch/src/kiotaClientFactory.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,34 @@ export class KiotaClientFactory {
99
/**
1010
* @public
1111
* @static
12-
* Returns an instance of HttpClient with the provided middlewares and custom fetch implementation
12+
* Returns an instance of HttpClient with the provided middlewares and custom fetch implementation both parameters are optional.
13+
* if not provided, the default fetch implementation and middlewares will be used.
14+
* @param {(request: string, init?: RequestInit) => Promise < Response >} customFetch - a Fetch API implementation
15+
* @param {Middleware[]} middlewares - an aray of Middleware handlers
16+
* If middlewares param is undefined, the httpClient instance will use the default array of middlewares.
17+
* Set middlewares to `null` if you do not wish to use middlewares.
18+
* If custom fetch is undefined, the httpClient instance uses the `DefaultFetchHandler`
1319
* @returns a HttpClient instance
20+
* @example
21+
* ```Typescript
22+
* // Example usage of KiotaClientFactory.create method with both customFetch and middlewares parameters provided
23+
* KiotaClientFactory.create(customFetch, [middleware1, middleware2]);
24+
* ```
25+
* @example
26+
* ```Typescript
27+
* // Example usage of KiotaClientFactory.create method with only customFetch parameter provided
28+
* KiotaClientFactory.create(customFetch);
29+
* ```
30+
* @example
31+
* ```Typescript
32+
* // Example usage of KiotaClientFactory.create method with only middlewares parameter provided
33+
* KiotaClientFactory.create(undefined, [middleware1, middleware2]);
34+
* ```
35+
* @example
36+
* ```Typescript
37+
* // Example usage of KiotaClientFactory.create method with no parameters provided
38+
* KiotaClientFactory.create();
39+
* ```
1440
*/
1541
public static create(customFetch: (request: string, init: RequestInit) => Promise<Response> = fetch as any, middlewares?: Middleware[]): HttpClient {
1642
const middleware = middlewares || MiddlewareFactory.getDefaultMiddlewares(customFetch);

0 commit comments

Comments
 (0)