52cik / express-mockjs Goto Github PK
View Code? Open in Web Editor NEWmockjs api middleware for Express
License: MIT License
mockjs api middleware for Express
License: MIT License
https://chaoxuelei.github.io/express-mock-doc/
需要的可以了解一下,支持restful
请问如何在下面的 data.json 中指定 @url 的值,
能让这个 mock 接口匹配到诸如 /performance/1
, /performance/2
, /performace/1;st=0
等等的接口请求呢?
/**
* 列表
*
* @url /performance
*/
{
"code": 200,
"data|10": [
{
"categoryId|+1": 1,
"categoryName": "@name",
"performanceQuantities": 0
}
]
}
系统:mac
node版本:v6.4.0
npm版本:5.3.0
问题:根据文档制作出现错误,具体如下:
TypeError: Cannot read property 'mock' of undefined
at /project/node_modules/express-mockjs/index.js:94:20
at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/project/node_modules/express/lib/router/index.js:317:13)
at /project/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/project/node_modules/express/lib/router/index.js:335:12)
at next (/project/node_modules/express/lib/router/index.js:275:10)
at expressInit (/project/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/project/node_modules/express/lib/router/index.js:317:13)
at /project/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/project/node_modules/express/lib/router/index.js:335:12)
at next (/project/node_modules/express/lib/router/index.js:275:10)
at query (/project/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/project/node_modules/express/lib/router/index.js:317:13)
at /project/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/project/node_modules/express/lib/router/index.js:335:12)
at next (/project/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/project/node_modules/express/lib/router/index.js:174:3)
at EventEmitter.handle (/project/node_modules/express/lib/application.js:174:10)
at Server.app (/project/node_modules/express/lib/express.js:38:9)
at emitTwo (events.js:106:13)
= = 现在返回太快了,可以允许自定义一个延迟时间么,这样可以写一下模拟数据返回中的处理流程。
我自己设置了一个方法,用来接收POST请求,但是感觉太麻烦了。
请问您有对于POST请求的参考方法吗,谢谢~
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.