SheetXL - v1.0.2
    Preparing search index...

    Interface IFetcher

    How a workbook reaches what lives outside it: the picture an IMAGE names, a web service's answer. A handler per URL scheme; a host registers its own to add authentication, or to serve a scheme of its own.

    Each workbook has one, given as IWorkbook.ConstructorOptions.fetcher, or a default that answers http: and https: with the global fetch.

    const fetcher = new Fetcher();
    fetcher.register('https', (url, init) => fetch(url, {
    ...init,
    headers: { ...init?.headers, Authorization: `Bearer ${token}` }
    }));
    const workbook = new Workbook({ fetcher });
    interface IFetcher {
        isIFetcher: true;
        fetch(input: string, init?: RequestInit): Promise<Response>;
        register(scheme: string, handler: Handler): () => void;
    }

    Implemented by

    Index
    isIFetcher: true

    For runtime type checking.

    • Fetches input with the handler registered for its scheme. A URL without a scheme goes to the https handler.

      Parameters

      • input: string
      • Optionalinit: RequestInit

      Returns Promise<Response>

      The response; rejects with a TypeError when no handler serves the scheme, as fetch does for a URL it cannot reach. In a browser the default handlers reject with a FormulaError.Blocked when the site responded but does not allow web pages to read it.

    • Serves a URL scheme with handler, replacing the handler it had.

      Parameters

      • scheme: string

        The scheme, with or without its colon: 'https', 'resource:'.

      • handler: Handler

      Returns () => void

      A function that removes the registration.