Skip to content

Commit c5d8962

Browse files
committed
docs: Add docs of RobustFetch
1 parent ad50834 commit c5d8962

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

rest/robustFetch.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@ export interface AbortError {
1414

1515
export type FetchError = NetworkError | AbortError;
1616

17+
/**
18+
* Represents a function that performs a network request using the Fetch API.
19+
*
20+
* @param input - The resource URL or a {@linkcode Request} object.
21+
* @param init - An optional object containing request options.
22+
* @returns A promise that resolves to a {@linkcode Result} object containing either a {@linkcode Request} or an error.
23+
*/
1724
export type RobustFetch = (
1825
input: RequestInfo | URL,
1926
init?: RequestInit,
2027
) => Promise<Result<Response, FetchError>>;
2128

2229
/**
23-
* Performs a network request using the Fetch API.
30+
* A simple implementation of {@linkcode RobustFetch} that uses {@linkcode fetch}.
2431
*
25-
* @param input - The resource URL or a `Request` object.
32+
* @param input - The resource URL or a {@linkcode Request} object.
2633
* @param init - An optional object containing request options.
27-
* @returns A promise that resolves to a `Result` object containing either a `Response` or an error.
34+
* @returns A promise that resolves to a {@linkcode Result} object containing either a {@linkcode Request} or an error.
2835
*/
2936
export const robustFetch: RobustFetch = async (input, init) => {
3037
const request = new Request(input, init);

0 commit comments

Comments
 (0)