xml-fetch
XMLHttpRequest as fetch
- supports abording
- promise interface, but this not Promise!!!
- get, post, delete, put
Installation
npm install --save-dev xml-fetch
Options
type TOptions = method?: string // Метод запроса async?: boolean // Тип запроса headers?: x: string: string // Заголовки timeout?: number // Время жизни запроса timeoutError?: string // Текст ошибки по истечению timeout;
Usage
"simple get"
Methods in 'http', return new instance xml-fetch
; const API_URL = 'https://you-api.com';const method = 'you-method';const query = param1: 'param1' param2: 'param2' ; http ;
; xmlFetch ;
"simple post"
http ;
Other methods
type TRequestParams = files?: x: string: // Массив файлов data?: x: string: |string // Данные; http: XmlFetch;http: XmlFetch;http: XmlFetch;http: XmlFetch;
Aborting
let request = http ; request;