From c5d896271cb314c616bb278f25531da8fec194b2 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:42:08 +0900 Subject: [PATCH] docs: Add docs of `RobustFetch` --- rest/robustFetch.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rest/robustFetch.ts b/rest/robustFetch.ts index 1785786..e9b5305 100644 --- a/rest/robustFetch.ts +++ b/rest/robustFetch.ts @@ -14,17 +14,24 @@ export interface AbortError { export type FetchError = NetworkError | AbortError; +/** + * Represents a function that performs a network request using the Fetch API. + * + * @param input - The resource URL or a {@linkcode Request} object. + * @param init - An optional object containing request options. + * @returns A promise that resolves to a {@linkcode Result} object containing either a {@linkcode Request} or an error. + */ export type RobustFetch = ( input: RequestInfo | URL, init?: RequestInit, ) => Promise>; /** - * Performs a network request using the Fetch API. + * A simple implementation of {@linkcode RobustFetch} that uses {@linkcode fetch}. * - * @param input - The resource URL or a `Request` object. + * @param input - The resource URL or a {@linkcode Request} object. * @param init - An optional object containing request options. - * @returns A promise that resolves to a `Result` object containing either a `Response` or an error. + * @returns A promise that resolves to a {@linkcode Result} object containing either a {@linkcode Request} or an error. */ export const robustFetch: RobustFetch = async (input, init) => { const request = new Request(input, init);