Code Monkey home page Code Monkey logo

express-mockjs's Issues

如何在 data.json 中指定 @url 为正则表达式?

请问如何在下面的 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
    }
  ]
}

Cannot read property 'mock' of undefined

系统: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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.