Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options typings missing #251

Closed
codeit-ninja opened this issue Sep 25, 2024 · 1 comment
Closed

Options typings missing #251

codeit-ninja opened this issue Sep 25, 2024 · 1 comment
Labels

Comments

@codeit-ninja
Copy link

codeit-ninja commented Sep 25, 2024

The type for options is object

wretch.options

var factory.options: (options: object, replace?: boolean) => void

wretch

wretch(_url?: string, _options?: {}): Wretch

I had a quik look in the code, and appearently WretchOptions in is not defined either, its just Record<string, any>.
Since I have little time I asked ChatGPT if he knew what all available types were.

Without veryifing it myself it gave me this:

type WretchOptions = {
    baseUrl?: string;                     // Base URL for requests
    headers?: Record<string, string>;     // Default headers for requests
    credentials?: 'omit' | 'same-origin' | 'include';  // CORS credentials mode
    mode?: 'cors' | 'no-cors' | 'same-origin'; // Request mode
    redirect?: 'follow' | 'error' | 'manual';  // Redirect behavior
    timeout?: number;                     // Timeout for requests in milliseconds
    signal?: AbortSignal;                 // AbortSignal to cancel requests
    retry?: {
        limit?: number;                   // Maximum number of retry attempts
        delay?: number;                   // Delay between retries in milliseconds
    } | number;                            // Can also be just a number for retry limit
    throwOnError?: boolean;               // Whether to throw on HTTP errors
    body?: string | object | FormData | URLSearchParams | ReadableStream; // Default body
    type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data'; // Content type
};
@elbywan
Copy link
Owner

elbywan commented Sep 25, 2024

Hey @codeit-ninja,

Yes the options argument is loosely typed on purpose to be able to pass various properties depending on the underlying fetch implementation (or to store arbitrary data).

@elbywan elbywan closed this as completed Sep 25, 2024
elbywan added a commit that referenced this issue Oct 29, 2024
elbywan added a commit that referenced this issue Oct 29, 2024
elbywan added a commit that referenced this issue Oct 29, 2024
elbywan added a commit that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants