maiwenan / axios-facker

mock any request you want

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

axios-facker

mock any request you want

axios-facker is based on axios, it helps you to replace a request baseURL with a mock url in your project

Install

npm install axios-facker --save-dev

Usage

import axios from 'axios';

axios.defaults.baseURL = 'https://api.example.com';

if (process.env.NODE_ENV === 'development') {
  const createAxiosFacker = require('axios-facker');
  const options = {
    fackerUrl: 'https://api.mock.com'
  };

  createAxiosFacker(options)(axios);
}

// axios will request `https://api.mock.com/user`
axios.get('/user');

when fetch a request, the request baseURL will be replaced by https://api.mock.com.

Options

fackerUrl

enabled

include

exclude

License

MIT

About

mock any request you want

License:MIT License


Languages

Language:JavaScript 68.9%Language:TypeScript 31.1%