@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
29 lines (28 loc) • 954 B
TypeScript
/**
* Lightweight HTTP utility for fetching server-rendered HTML fragments
* and handling common concerns like CSRF tokens and response parsing.
*/
declare class DprHtmlClient {
/**
* Fetches an HTML fragment from the server and parses it into a DocumentFragment.
* Returns null if the response indicates no content change (204).
*
* @static
* @param {string} url
* @param {string} [csrfToken]
* @return {*} {(Promise<DocumentFragment | null>)}
* @memberof DprHtmlClient
*/
static fetchFragment(url: string, csrfToken?: string): Promise<DocumentFragment | null>;
/**
* Extracts the CSRF token from a DOM element's dataset.
* Throws an error if the token is not present.
*
* @static
* @param {HTMLElement} element
* @return {*} {string}
* @memberof DprHtmlClient
*/
static getCsrfToken(element: HTMLElement): string;
}
export default DprHtmlClient;