@ackee/antonio-core
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

ackee|Antonio

GitHub license CI Status PRs Welcome Dependency Status bundlephobia bundlephobia node version

@ackee/antonio-core

HTTP client built on Fetch API.

Table of contents


Install

yarn add @ackee/antonio-core -S

Usage

import { Antonio } from '@ackee/antonio-core';

const api = new Antonio({
    baseURL: 'https://jsonplaceholder.typicode.com/',
});

function* fetchTodos() {
    // Since api.get returns generator function, `yield*` is required.
    const { data, request, response } = yield* api.get('/todos', {
        params: {
            page: 1,
            limit: 20,
        },
    });
}

API

new Antonio(requestConfig?: RequestConfig, generalConfig?: GeneralConfig)

Creates a new instance of Antonio with custom request config and general config:

import { Antonio } from '@ackee/antonio-core';

const api = new Antonio({
    baseURL: 'https://some-domain.com/api/',
});

Instance methods

api.get(url: string, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.delete(url: string, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.head(url: string, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.options(url: string, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.post(url: string, data: RequestBody, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.put(url: string, data: RequestBody, requestConfig?: RequestConfig): Generator<any, RequestResult>

api.patch(url: string, data: RequestBody, requestConfig?: RequestConfig): Generator<any, RequestResult>

generalConfig: GeneralConfig

Optional @ackee/antonio-core configuration:

{
    // Default is [`loglevel`](https://www.npmjs.com/package/loglevel)
    logger: loglevel,
}

Package Sidebar

Install

npm i @ackee/antonio-core

Weekly Downloads

178

Version

5.0.0

License

MIT

Unpacked Size

305 kB

Total Files

110

Last publish

Collaborators

  • pivl
  • hofp37
  • grissius
  • ackeecz
  • horaklukas
  • borecekbaji
  • davidbilik