mockios
v1.2.4
Published
A library that helps run-time testing by putting fake data instead of Axios.
Downloads
6
Readme
mockios
A library that helps run-time testing by putting fake data instead of Axios.
Installing
When use npm
$ npm install --save-dev mockios
When use yarn
$ yarn add --dev mockios
How to use
import axios from "axios";
import mockios, { MockDataType } from "mockios";
const mockData: MockDataType = {
get: {
// method
"/hello": [
// url
{ ok: true, message: "hello world" }, // response body
{ baseURL: "http://localhost:3000" }, // response config
],
},
};
const query =
process.env.NODE_ENV === "development" ? mockios(mockData) : axios;
query.get("/hello").then(({ data }) => {
console.log(data); // { ok: true, message: 'hello world' }
});