Socket
Socket
Sign inDemoInstall

@aspida/axios

Package Overview
Dependencies
24
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aspida/axios

axios client for aspida


Version published
Weekly downloads
14K
decreased by-9.04%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

@aspida/axios


aspida
npm version npm download

axios client for aspida.


Getting Started

Installation

  • Using npm:

    $ npm install aspida @aspida/axios axios
    
  • Using Yarn:

    $ yarn add aspida @aspida/axios axios
    

Make HTTP request from application

src/index.ts

import axios from "axios";
import aspida from "@aspida/axios";
import api from "../api/$api";

const axiosConfig = { timeout: 3000, baseURL: "https://example.com/api" };
const client = api(aspida(axios, axiosConfig));
(async () => {
  const userId = 0;
  const limit = 10;

  await client.v1.users.post({ name: "mario" });

  const res = await client.v1.users.get({ query: { limit } });
  console.log(res);
  // req -> GET: https://example.com/api/v1/users/?limit=10
  // res -> { status: 200, data: [{ id: 0, name: "mario" }], headers: {...} }

  const user = await client.v1.users._userId(userId).$get();
  console.log(user);
  // req -> GET: https://example.com/api/v1/users/0
  // res -> { id: 0, name: "mario" }
})();

License

@aspida/axios is licensed under a MIT License.

Keywords

FAQs

Last updated on 15 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc