@ventum-digital/plugin-fetch
Version:
Functions for fetching data from SailPoint IdentityIQ REST API
26 lines (25 loc) • 1.7 kB
TypeScript
/**
* Performs an HTTP request using the Fetch API with additional plugin-specific configurations.
*
* @param {string} url - The URL to which the request is sent. You can use {@link getUrlFactory}.
* @param {RequestInit} options - The options used to configure the HTTP request, such as method, headers, and body.
* @return {Promise<any>} A promise that resolves with the parsed JSON response if the request is successful or rejects with an error if the request fails.
* @throws {Error} If the response is not ok (status code outside the range 200-299), an error is thrown with the status and response message.
*/
export declare function pluginFetch(url: string, options?: RequestInit): Promise<any>;
/**
* Fetches data from the provided URL using {@link pluginFetch} and retrieves the specified key from the response.
*
* @param {string} url - The URL to fetch the data from. You can use {@link getUrlFactory}.
* @param {string} key - The key to extract from the fetched response.
* @return {Promise<any>} A promise that resolves to the value associated with the specified key in the response, or an empty string if an error occurs.
*/
export declare function pluginFetchKey(url: string, key: string): Promise<any>;
/**
* Generates a URL creation function for a specific plugin.
*
* @param {string} pluginName - The name of the plugin for which the URL factory is being created.
* @return {(path: string) => string} - A function that takes a path and returns the complete URL for the given plugin. Leading slashes in the path are removed.
*/
export declare function getUrlFactory(pluginName: string): (path: string) => string;
export declare function getRestUrl(path: string): string;