npaw-plugin-nwf
Version:
NPAW's Plugin
28 lines (27 loc) • 682 B
TypeScript
export type HttpRequestOptions = {
url: string;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
headers?: Record<string, string>;
body?: any;
timeoutMs?: number;
withCredentials?: boolean;
};
export type HttpResponse = {
status: number;
body: string;
xhr: XMLHttpRequest;
};
export type HttpHandle = {
promise: Promise<HttpResponse>;
abort: () => void;
xhr: XMLHttpRequest;
};
/**
* Minimal, robust HTTP client using XMLHttpRequest (compatible with existing FakeXHR in tests).
* - Promise-based API
* - Timeout support
* - Abort handle
*/
export default class HttpClient {
static request(opts: HttpRequestOptions): HttpHandle;
}