@gooddata/gooddata-js
Version:
GoodData JavaScript SDK
70 lines (69 loc) • 2.24 kB
TypeScript
export declare function handlePolling(url: string, settings: any, sendRequest: (url: string, settings: any) => any): Promise<ApiResponse>;
export interface IPackageHeaders {
name: string;
version: string;
}
export declare function originPackageHeaders({ name, version }: IPackageHeaders): {
"X-GDC-JS-PKG": string;
"X-GDC-JS-PKG-VERSION": string;
};
export declare class ApiError extends Error {
cause: any;
constructor(message: string, cause: any);
}
export declare class ApiResponseError extends ApiError {
response: any;
responseBody: any;
constructor(message: string, response: any, responseBody: any);
}
export declare class ApiNetworkError extends ApiError {
}
export declare class ApiResponse {
response: Response;
responseBody: string;
constructor(response: Response, responseBody: string);
readonly data: any;
getData(): any;
getHeaders(): Response;
}
export declare class XhrModule {
private fetch;
private configStorage;
private tokenRequest?;
constructor(fetch: any, configStorage: any);
/**
* Back compatible method for setting common XHR settings
*
* Usually in our apps we used beforeSend ajax callback to set the X-GDC-REQUEST header with unique ID.
*
* @param settings object XHR settings as
*/
ajaxSetup(settings: any): void;
ajax(originalUrl: string, customSettings?: {}): Promise<ApiResponse>;
/**
* Wrapper for xhr.ajax method GET
*/
get(url: string, settings?: any): Promise<ApiResponse>;
/**
* Wrapper for xhr.ajax method HEAD
*/
head(url: string, settings?: any): Promise<ApiResponse>;
/**
* Wrapper for xhr.ajax method POST
*/
post(url: string, settings?: any): Promise<ApiResponse>;
/**
* Wrapper for xhr.ajax method PUT
*/
put(url: string, settings: any): Promise<ApiResponse>;
/**
* Wrapper for xhr.ajax method DELETE
*/
del(url: string, settings?: any): Promise<ApiResponse>;
private createRequestSettings;
private continueAfterTokenRequest;
private handleUnauthorized;
private logDeprecatedRestApiCall;
private isRestApiDeprecated;
private verifyRestApiDeprecationStatus;
}