123456789101112131415161718 |
- export interface BrowserTransportOptions {
- url: string;
- data: any;
- }
- export const makeXHRRequest = (options: BrowserTransportOptions): PromiseLike<XMLHttpRequestResponseType> => {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
- xhr.onerror = reject;
- xhr.onreadystatechange = (): void => {
- if (xhr.readyState === 4) {
- resolve(xhr.response);
- }
- };
- xhr.open('POST', options.url);
- xhr.send(options.data);
- });
- };
|