the default ffetch instance with a reasonable default set of addons

you can use this as a base to create your project-specific fetch instance, or use this as is.

this is not exported as ffetch because most of the time you will want to extend it, and exporting it as ffetch would make them clash in import suggestions, and will also make it prone to subtle bugs.

import { ffetchBase } from '@fuman/fetch'

const ffetch = ffetchBase.extend({
baseUrl: 'https://example.com',
headers: { ... },
addons: [ ... ],
})

Properties

delete: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a DELETE request

extend: <
    const Addons extends FfetchAddon<any, any>[],
    Combined extends
        { request: object; response: object } = CombineAddons<Addons, {}, {}>,
>(
    baseOptions: FfetchBaseOptions<Addons> & Combined["request"],
) => Ffetch<
    TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon & Combined["request"],
    Combined["response"],
>

extend the base options with the given options

note: addons, middlewares and headers will be merged with the base options, the rest of the options will be overridden

get: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a GET request

head: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a HEAD request

options: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making an OPTIONS request

patch: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a PATCH request

post: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a POST request

put: (
    url: string,
    params?: FfetchOptions & TimeoutAddon & QueryAddon & FormAddon & MultipartAddon & RetryAddon,
) => FfetchResult & object

shorthand for making a PUT request