Closed Anubhav22still closed 10 months ago
Check the content of db.json, there seem to be a syntax error
my db.json is empty, I need to create localhost:3000 to test api for my project with this .
File can't be empty, copy this in your db.json
and edit it with the resources for your project:
{
"posts": [
{ "id": "1", "title": "a title" },
{ "id": "2", "title": "another title" }
],
"comments": [
{ "id": "1", "text": "a comment about post 1", "postId": "1" },
{ "id": "2", "text": "another comment about post 1", "postId": "1" }
],
"profile": {
"name": "typicode"
}
}
same problem
Try updating to latest version
Hey, i tried it with a small JSON and it worked after i distributed ID's. Hope it helps you. ps: i use Node.js v21.6.1
it shows : --watch/-w can be omitted, JSON Server 1+ watches for file changes by default undefined:1
SyntaxError: Unexpected end of JSON input at JSONFile.parse ()
at JSONFile.read (file:///C:/Users/anubh/AppData/Roaming/npm/node_modules/json-server/node_modules/lowdb/lib/adapters/node/DataFile.js:17:31)
at async Observer.read (file:///C:/Users/anubh/AppData/Roaming/npm/node_modules/json-server/lib/observer.js:21:22)
at async Low.read (file:///C:/Users/anubh/AppData/Roaming/npm/node_modules/json-server/node_modules/lowdb/lib/core/Low.js:16:22)
at async file:///C:/Users/anubh/AppData/Roaming/npm/node_modules/json-server/lib/bin.js:85:1
Node.js v18.15.0
please help