Json-server: Property render does not exist on type Router

Created on 6 Mar 2019  路  4Comments  路  Source: typicode/json-server

Custom output example
To modify responses, overwrite router.render method:

const router = jsonServer.router(path.join(__dirname, '../db.json'));

// In this example, returned resources will be wrapped in a body property
router.render = (req, res) => {
  res.jsonp({
    body: res.locals.data
  })
}

Using router.render throws property render does not exist on type router

All 4 comments

The error occurs when you execute the node script or when you visit some route?
The code itself it's not failing.

The error is shown in the IDE and also when I execute the script. But have figured out another solution. i am just going to close this issue.

@Rutvik17 What was your other solution? I'm having the same problem.

@b4dnewz as described, router.render just doesn't exist, so we can't assign to it as the documentation states.

@Rutvik17 What was your other solution? I'm having the same problem.

@b4dnewz as described, router.render just doesn't exist, so we can't assign to it as the documentation states.

Sorry I actually don't remember what i did, i will need to find the solution.

Was this page helpful?
0 / 5 - 0 ratings