npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

axios-classification

v0.3.2

Published

Use axios classification

Readme

axios classification

자주 사용하는 라이브러리인 axios를 class화한 모듈입니다. :)

⚡ Install

$ npm i axios-classification

🤹‍♂️ How to use

axios-classification를 import 하여 AxiosBase를 가져옵니다. AxiosBase는 Class 객체이기에, 객체 생성을 하여 사용합니다.

Import module

import { AxiosBase } from 'axios-classification';

Create object

const config = {
  baseURL: 'http://example.co.kr',
};

const axiosBase = new AxiosBase(config);

💡 해당 config는 Axios 설정을 기반으로 합니다.

Post / Get / Put / Patch / Delete

메소드들의 매개변수는 모두 동일합니다. 제네릭에서 첫번째 타입은 파라미터 형식, 두번째 타입은 응답받을 형식 입니다.

interface IExampleParam {
  id: number;
  name: string;
}

interface IResponseData {
  status: boolean;
}

const params = {
  id: 1,
  name: 'test',
};

// Post
const { data } = axiosBase.post<IExampleParam, IResponseData>('/path/to', params);

// Get
const { data } = axiosBase.get<IExampleParam, IResponseData>('/path/to', params);

// Put
const { data } = axiosBase.put<IExampleParam, IResponseData>('/path/to', params);

// Patch
const { data } = axiosBase.patch<IExampleParam, IResponseData>('/path/to', params);

// Delete
const { data } = axiosBase.delete<IExampleParam, IResponseData>('/path/to', params);

console.log(data); // { status: true }

만약 넘기는 파라미터, 또는 응답이 없다면, undefined 타입으로 설정해주세요.

interface IResponseData {
  status: boolean;
}

// Get
const { data } = axiosBase.get<undefined, IResponseData>('/path/to');

Setting bearer auth token

만약 헤더에 token을 넣어야한다면 setBearerToken을 사용하세요. 헤더의 AuthorizationBearer ${token}}을 자동으로 넣어줍니다. :)

axiosBase.setBearerToken('123456789');

/*
{
  header : "Bearer 123456789"
}
*/

Setting header

다른 값을 헤더에 넣어야한다면 아래 함수들을 사용하세요.

  • setCommonHeader
  • setDeleteHeader
  • setGetHeader
  • setHeadHeader
  • setPatchHeader
  • setPostHeader
  • setPutHeader

해당 함수들의 파라미터들은 모두 같아요.

axiosBase.setCommonHeader({
  'Content-type': 'application/json',
});

axiosBase.setPostHeader({
  test: 'test',
});

Interceptor

요청하기 전, 또는 응답 전에 인터셉트를 해야한다면 setRequestInterceptor, setResponseInterceptor를 사용하세요. parameter는 두 함수가 동일하게 (callback function, callback function, options) 입니다.

// request interceptor
axiosBase.setRequestInterceptor(
  (config) => {
    // content
    return config;
  },
  (error) => {
    // content
    throw error;
  },
);

// response interceptor
axiosBase.setResponseInterceptor(
  (response) => {
    // content
    return response;
  },
  (error) => {
    // content
    throw error;
  },
);

Extends class

class를 만들고, 상속을 받아 사용할 수 있습니다. 원하는 property를 class 내부에서 사용해야 한다면 아래 방법처럼 사용하세요.

import { AxiosBase } from 'axios-classification';

class Test extends AxiosBase {
  private readonly key = '1234567890';

  getKey() {
    return this.key;
  }
}

export const TestClient = new Test({
  baseURL: 'your url',
});

👀 Example

example를 참고하세요. :)

🎊 Thanks

AxiosBase class에서 제공해야한다고 생각하는 axios의 기능들은 issue 또는 PR 주세요. :)