Skip to content

Commit 44bdfb4

Browse files
authored
Update README.md
1 parent 0861dfe commit 44bdfb4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,15 @@ server.listen(3000, function () {
354354
$ node server.js
355355
```
356356

357-
For an in-memory database, you can pass an object to `jsonServer.router()`.
357+
The path you provide to the `jsonServer.router` function is relative to the directory from where you launch your node process. If you run the above code from another directory, it’s better to use an absolute path:
358+
359+
```js
360+
var path = require('path')
361+
var router = jsonServer.router(path.join(__dirname, 'db.json'))
362+
```
363+
364+
For an in-memory database, simply pass an object to `jsonServer.router()`.
365+
358366
Please note also that `jsonServer.router()` can be used in existing Express projects.
359367

360368
#### Custom routes example

0 commit comments

Comments
 (0)