Skip to main content

FetchService

Stentor API Reference


Stentor API Reference / stentor-service-fetch/src / FetchService

Abstract Class: FetchService

Defined in: packages/stentor-service-fetch/src/FetchService.ts:33

Abstract service for services that primarily rely on the fetch API.

It includes built-in timeout feature to better keep track of external APIs.

Export​

FetchService

Extends​

Constructors​

Constructor​

new FetchService(props?): FetchService

Defined in: packages/stentor-service-fetch/src/AbstractService.ts:13

Parameters​

props?​

BaseService

Returns​

FetchService

Inherited from​

AbstractService.constructor

Properties​

timeout​

readonly timeout: number = 1000

Defined in: packages/stentor-service-fetch/src/AbstractService.ts:9

Timeout

Inherited from​

AbstractService.timeout


retryAttempts​

readonly retryAttempts: number = 0

Defined in: packages/stentor-service-fetch/src/AbstractService.ts:10

How many attempts to make on the API

Inherited from​

AbstractService.retryAttempts


logs​

readonly logs: boolean = false

Defined in: packages/stentor-service-fetch/src/AbstractService.ts:11

Log information from the service

Inherited from​

AbstractService.logs

Methods​

fetch()​

protected fetch(url, options?): Promise\<Response>

Defined in: packages/stentor-service-fetch/src/FetchService.ts:39

Wrapper around fetch to add some basic diagnostics

Will throw a TimeoutError if the timeout is reached.

Parameters​

url​

string

options?​

RequestInit & WithTimeout

Returns​

Promise\<Response>