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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@newbiz/axios-libs

v1.2.0

Published

신사업 프론트엔드 Axios 래핑 라이브러리

Downloads

21

Readme

Axios Libs

npm node types downloads license

신사업개발실 서비스/어드민 프론트엔드 Axios 래핑 라이브러리.

This project was generated by Vessel. For a simple and quick reference, click here.

About

Axios 라이브러리를 래핑한 RESTful API 처리 라이브러리.

Installation

해당 모듈을 사용 할 프로젝트에서는 아래와 같이 의존성 모듈로 설치한다.

$ npm install --save @newbiz/axios-libs
or
$ yarn add @newbiz/axios-libs

Usage

최초 랜더링 되는 앱에 아래와 같이 axiosDefaultConfig를 이용하여 설정 부분을 추가해주면 된다.

Vue.js example

import { axiosDefaultConfig } from '@newbiz/axios-libs'

export default {
  ...
  created () {
    ...
    axiosDefaultConfig({
      baseURL: '/test',
      method: 'get',
      timeout: 3000,
      isThrowsOnError: true,
      onInvalidate (which, error) {
        console.log('is error on request or response?', which)
        console.error(error.message)
      },
    })
    ...
  },
  ...
}

axios 라이브러리는 아래와 같이 import하여 사용한다.

import { axios } from '@newbiz/axios-libs'

Configuration

axiosDefaultConfig() 메소드는 이미 오버라이드 된 axios 기본 설정을 사용자에 맞게 오버라이드 시켜줄 수 있다. interface 선언과 아래 샘플을 참고하면 된다.

import { axiosDefaultConfig, AxiosRequestConfig } from '@newbiz/axios-libs';

const axiosConfig: AxiosRequestConfig = {
  defaults: { // default axios request config
    baseURL: '',
    headers: {
      common: {
        'Content-Type': 'application/json;charset=UTF-8',
      },
      post: {
        'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
      },
    },
    withCredentials: true,
    timeout: 5000,  
  },

  isShowLog: process.env.NODE_ENV !== 'production', // 로그 출력 여부
  isLogFullResponse: false, // response 로그에 전체 항목 표시 여부
  isThrowsOnError: true, // response 오류 발생시 throw 할 것인지 여부

  // request config에서 baseURL 및 url의 key에 해당되는 value값으로 치환한다.
  // (로컬서버에서 프록시 사용시 코드상의 url을 배포단계별로 조작하지 않아도 되게하기 위함) 
  resolveRequestURL: process.env.NODE_ENV !== 'production' ? undefined : {
    '/api': 'https://api.wemakeprice.com',
  },

  // callback functions
  onRequest (config, currReqs) {
    console.log(config, currReqs);
    // 만약 config 변경이 있다면 리턴하여 반영, 그렇지 않으면 리턴 불필요.
    // return config;
  },
  onResponse (response, currReqs) {
    console.log(response, currReqs);
    // onRequest와 마찬가지로 response 변경시 리턴.
    // return response;
  },
  onRequestError (error, currReqs) { console.log(error, currReqs); },
  onResponseError (error, currReqs) { console.log(error, currReqs); },
  onInvalidate (which, error) {
    // response 오류처리만 이곳에서 한다.
    // request 정보는 error.request에서, response 정보는 error.response에서 확인 가능.
    if (which === 'request') {
      console.error(`Request error: ${error}`);
    } else {
      console.error(`Response error: ${error}`);
    }
  },
}

axiosDefaultConfig(axiosConfig);

Change Log

해당 프로젝트의 CHANGELOG.md 파일 참조.

License

해당 프로젝트의 LICENSE 파일 참조.