uni-mock

2.1.7 • Public • Published

uni-mock

APM

NPM

data mock service for developer

Installation

npm install uni-mock -save-dev

Run

uni-mock

Config

touch a config file named um.config.js to set your own mock service

  • path Set the listening directory according to the project
  • suffix Set the service server path suffix
  • host Set the service server host
  • port Set the service server port

Example

um.config.js

module.exports = {
    path: "/mock",
    suffix: "_MOCK_",
    host: "localhost",
    port: 8080
}

mock.json

{
    "reponseCode": "0000",
    "reponseData": {
        "name": "Tom"
    }
}

mock.js

module.exports = function (params){
    if(params.name === 'Tom'){
        return{
            "reponseCode": "0000",
            "reponseData": {
                "name": "Tom"
            } 
        }
    }else{
        return{
            "reponseCode": "9999",
            "reponseData": "invalid user name!"
        }
    }
    
}

Dependents (0)

Package Sidebar

Install

npm i uni-mock

Weekly Downloads

1

Version

2.1.7

License

MIT

Unpacked Size

47.9 kB

Total Files

7

Last publish

Collaborators

  • gavinsuen100