can't watch multiple files with json-server
create files as shown below
db.js
var firstRoute = require('./jsonfile1.json');var secondRoute = require('./jsonfile2.json');var thirdRoute = require('./jsonfile3.json');var fourthRoute = require('./jsonfile4.json');// and so onmodule.exports = function() {return {firstRoute : firstRoute,secondRoute : secondRoute,thirdRoute : thirdRoute,fourthRoute : fourthRoute// and so on }}
server.js
var jsonServer = require('json-server')var server = jsonServer.create()var router = jsonServer.router(require('./db.js')())var middlewares = jsonServer.defaults()server.use(middlewares)server.use(router)server.listen(3000, function () {console.log('JSON Server is running')})
Now go to the directory where you have created both these files and open command line and run the code below
node server.js
That's it now go to the browser and go to localhost:3000 ,You shall see the routes that created for different files,you may use it directly.