I am working with json-server
. I have installed it with npm install -g json-server
and am watching using
json-server --watch db.json
I have added db.json
file in app folder with below data
{
"product": [
{
"userId": 1,
"firstName": "Krish",
"lastName": "Lee",
"phoneNumber": "123456",
"emailAddress": "krish.lee@learningcontainer.com"
},
{
"userId": 5,
"firstName": "jone",
"lastName": "mac",
"phoneNumber": "111111111",
"emailAddress": "jone.mac@learningcontainer.com"
}
]
}
but only http://localhost:3000/
is working. It shows
Congrats!
You're successfully running JSON Server
✧*。٩(ˊᗜˋ*)و✧*。
Resources
/posts 1x
/comments 1x
/profile object
To access and modify resources, you can use any HTTP method:
GET POST PUT PATCH DELETE OPTIONS
undefined
Documentation
README
To replace this page, create a ./public/index.html file.
http://localhost:3000/product
is not working. How can I fix this issue?
The first time you try to run json-server@0
, if it can't find the supplied source, load.js
writes out the default example for you:
> json-server --watch db.json
\{^_^}/ hi!
Loading db.json
Oops, db.json doesn't seem to exist
Creating db.json with some default data
Done
Resources
http://localhost:3000/posts
http://localhost:3000/comments
http://localhost:3000/profile
Home
http://localhost:3000
On subsequent runs, because the file now exists, the server seems to be starting up just fine but isn't using the db.json
file you think it is. For that reason, this seems like a bit of a misfeature.
I opened a PR to require this behaviour to be explicitly requested; based on the prerelease -alpha
versions it looks like this automatic creation won't be a feature of json-server@1
.