UNPKG

@openshift-console/dynamic-plugin-sdk

Version:

Provides core APIs, types and utilities used by dynamic plugins at runtime.

34 lines (33 loc) 1.73 kB
import { ConsoleFetchText, ConsoleFetchJSON, ConsoleFetch } from '../../extensions/console-types'; /** * A custom wrapper around `fetch` that adds console-specific headers and allows for retries and timeouts. * It also validates the response status code and throws an appropriate error or logs out the user if required. * @param url The URL to fetch * @param options The options to pass to fetch * @param timeout The timeout in milliseconds * @returns A promise that resolves to the response. */ export declare const consoleFetch: ConsoleFetch; /** * A custom wrapper around `fetch` that adds console-specific headers and allows for retries and timeouts. * It also validates the response status code and throws an appropriate error or logs out the user if required. * It returns the response as a JSON object. * Uses consoleFetch internally. * @param url The URL to fetch * @param method The HTTP method to use. Defaults to GET * @param options The options to pass to fetch * @param timeout The timeout in milliseconds * @returns A promise that resolves to the response as text or JSON object. */ export declare const consoleFetchJSON: ConsoleFetchJSON; /** * A custom wrapper around `fetch` that adds console-specific headers and allows for retries and timeouts. * It also validates the response status code and throws an appropriate error or logs out the user if required. * It returns the response as a text. * Uses `consoleFetch` internally. * @param url The URL to fetch * @param options The options to pass to fetch * @param timeout The timeout in milliseconds * @returns A promise that resolves to the response as text or JSON object. */ export declare const consoleFetchText: ConsoleFetchText;