Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ackee/antonio

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ackee/antonio

A HTTP client built on fetch with axios-like API.

  • 4.0.0-alpha.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54
increased by68.75%
Maintainers
3
Weekly downloads
 
Created
Source

ackee|Antonio

GitHub license CI Status PRs Welcome Dependency Status bundlephobia bundlephobia

Antonio

A HTTP client built on Fetch API with similar API to axios.

Table of contents


Installing

$ yarn add @ackee/antonio -S

Setup

Create a new instance and you're ready to go.

import { create } from '@ackee/antonio';

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

Usage Examples

import { api } from '...';

api.get('/todos').then(({ data, request, response }) => {
    // ...
});

api.post('/todos', {
    title: 'Lorem ipsum',
});

api.put(
    '/todos/:id',
    {
        title: 'Not lorem ipsum',
    },
    {
        uriParams: {
            id: '2',
        },
    },
);

api.get('/todos/:id', {
    uriParams: {
        id: '2',
    },
});

api.delete('/todos/:id', {
    uriParams: '2',
});

API

create([config])

import * as Antonio from '@ackee/antonio';

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

Instance methods

antonio#get(url[, config])

antonio#delete(url[, config])

antonio#head(url[, config])

antonio#options(url[, config])

antonio#post(url[, data[, config]])

antonio#put(url[, data[, config]])

antonio#patch(url[, data[, config]])

Request config

These are the available config options for making requests. None of these is required.

{
    // `baseURL` will be prepended to `url` unless `url` is absolute.
    // It can be convenient to set `baseURL` for an instance of antonio to pass relative URLs
    // to methods of that instance.
    // Default: undefined
    baseUrl: 'https://jsonplaceholder.typicode.com/',

    // Default: "json"
    // Options: "json" | "blob" | "text" | "formData" | undefined
    responseType: "json",

    // Default: undefined
    // Options: object | undefined
    uriParams: {
        id: '2'
    },

    // `headers` are custom headers to be sent
    // Must be a plain object or a Headers object
    // Default: undefined
    headers: new Headers({
        'X-Custom-Header': 1234
    }),

    // `searchParams` are the URL parameters to be sent with the request
    // Must be a plain object or a URLSearchParams object
    // Default: undefined
    searchParams: new URLSearchParams({
        query: 'foo'
    }),

    // Following props are pass to Request constructor,
    // see the official docs https://developer.mozilla.org/en-US/docs/Web/API/Request/Request
    mode: undefined,
    credentials: undefined,
    cache: undefined,
    redirect: undefined,
    referrer: undefined,
    referrerPolicy: undefined,
    integrity: undefined,
    keepalive: undefined,
    signal: undefined,
}

FAQs

Package last updated on 08 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc