You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,15 @@ server.listen(3000, function () {
354
354
$ node server.js
355
355
```
356
356
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
+
358
366
Please note also that `jsonServer.router()` can be used in existing Express projects.
0 commit comments