Can mockjs simulation data be independently generated and used by url like json-server?

can mockjs simulate data generate url independently as json-server does

Mar.05,2021

cannot, unless you start a server with node to introduce mock generation data


it's easy to start a service with express,

let express = require('express')
let app = express()

let Mock = require('mockjs')
let defalut = {
  errorCode: 0,
  message: ''
}
// 
app.get('/common/getCity', (req, res) => {
  let data = Object.assign({}, defalut, {
    data: [{
      id: 1,
      label: ''
    },
    {
      id: 2,
      label: ''
    },
    {
      id: 3,
      label: ''
    },
    {
      id: 4,
      label: ''
    },
    {
      id: 5,
      label: ''
    }]
  })
  res.send(data)
})

var server = app.listen(3007, () => {
  let host = server.address().address
  let port = server.address().port
  console.log("Mock server start at http://%s:%s", host, port)
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eac6c7-46b56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eac6c7-46b56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?