Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Question about watching multiple files with json-server

I followed the best solution below: can't watch multiple files with json-server

db.js

var firstRoute  = require('./jsonfile1.json');
var secondRoute = require('./jsonfile2.json');

module.exports = function() {
  return {
    firstRoute  : "/people",
    secondRoute : "/dates"
  }
}

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')
})

Then I ran node server.js

I get this error: Error: Type of "firstRoute" (string is not supported. Use objects or arrays of objects

Sorry, I am not too familiar with backend and wanted to use json-server to practice. What is wrong here?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!