Function withHeaders

  • Attach headers to request headers from callback function.

    Note: This function does not work with multiple asynchronous operations by default. If you want to apply to multiple asynchronous operations, you need to call the ensure function before each asynchronous operation. (the first one doesn't need)

    Type Parameters

    • T

    Parameters

    • fn: ((ensure) => T)

      The callback function to request network.

        • (ensure): T
        • Parameters

          • ensure: (() => void)
              • (): void
              • Returns void

          Returns T

    • headers: HeadersInit

      It will be attached to request headers from callback function.

    Returns T

    Example

    const result = withHeaders(() =>
    indexer.character.getMany(address),
    { 'X-My-Header': 'foo' }
    )

Generated using TypeDoc