@leomax/request
v0.0.8
Published
Ajax library
Downloads
11
Readme
@leomax/request
Библиотека для клиентских запросов.
Установка
npm i -S @leomax/request
yarn add @leomax/request
Подключение
// Основной инстанс
import request from '@leomax/request';
// Класс для создания собственного инстанса и хуков
import Request from '@leomax/request/Request';
// Драйвер под XMLHttpRequest
import XHRDriver from '@leomax/request/driver/XHR';
API
request.<method>(
url: string | IRequestSchema,
options?: IRequestSchema
): Promise<IRequestResponse>;
method
- get
- put
- head
- patch
- delete
- options
IRequestSchema
Допустимые опции
{
url: string,
base: string
}
Использование
import request from '@leomax/request';
request
.get('/path', { id: 1 })
.then(({ data, status }) => {
// ...
})
.catch(({ error, status }) => {
// ...
});