handle-mock
Version:
An express middleWare function to control request forward,if the request match the config, it will return the mock data,otherwise the reauet will forward to the target host
20 lines (17 loc) • 495 B
Markdown
An express middleWare function to control request forward,if the request match the config, it will return the mock data,otherwise the reauet will forward to the target host
usage:
```js
const config = [
{
url: '/search_api/v1/search',
params: {
name: 'yyyy',
},
mockData: { m: 'mmm' },
target: 'https://api.juejin.cn',
},
]
app.use(handleMock(config, 'https://api.juejin.cn'));
```