Skip to main content
Version: Next

createFetchApi()

Home > @backstage/core-app-api > createFetchApi

Builds a fetch API, based on the builtin fetch wrapped by a set of optional middleware implementations that add behaviors.

Signature:

function createFetchApi(options: {
baseImplementation?: typeof fetch | undefined;
middleware?: FetchMiddleware | FetchMiddleware[] | undefined;
}): FetchApi;

Parameters

Parameter

Type

Description

options

{ baseImplementation?: typeof fetch | undefined; middleware?: FetchMiddleware | FetchMiddleware[] | undefined; }

**Returns:**

FetchApi

Remarks

The middleware are applied in reverse order, i.e. the last one will be "closest" to the base implementation. Passing in [M1, M2, M3] effectively leads to M1(M2(M3(baseImplementation))).