A node-fetch actor that listens on the 'init' bus.

It will call fetch with either action.input or action.url.

Hierarchy (view full)

Constructors

Properties

Actor that must be registered in the bus before this actor.

The bus this actor subscribes to.

fetchInitPreprocessor: IFetchInitPreprocessor
name: string

The name for this actor.

Default

{<rdf:subject>}
userAgent: string

Methods

  • Deinitialize this actor. This should be used for cleaning up things when the application is shut down, such as closing files and removing temporary files.

    Returns Promise<any>

    A promise that resolves when the actor has been deinitialized.

  • Initialize this actor. This should be used for doing things that take a while, such as opening files.

    Returns Promise<any>

    A promise that resolves when the actor has been initialized.

  • Perform a fetch request, taking care of retries

    Parameters

    • fetchFn: ((input, init?) => Promise<Response>)
        • (input, init?): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optional init: RequestInit

          Returns Promise<Response>

    • requestInput: RequestInfo | URL

      Url or RequestInfo to pass to fetchFn

    • requestInit: RequestInit

      RequestInit to pass to fetch function

    • retryCount: number

      Maximum retries after which to abort

    • retryDelay: number

      Time in milliseconds to wait between retries

    • throwOnServerError: boolean

    Returns Promise<Response>

    a fetch Response object

  • Converts WhatWG streams to Node streams if required. Returns the input in case the stream already is a Node stream.

    Parameters

    • body: null | ReadableStream<any>

    Returns ReadableStream

    A node stream.