'json-server not showing URL for JSON data
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": "[email protected]"
},
{
"userId": 5,
"firstName": "jone",
"lastName": "mac",
"phoneNumber": "111111111",
"emailAddress": "[email protected]"
}
]
}
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?
Solution 1:[1]
db.json is supposed to be set up in in the root folder? you indicated you put yours in the app folder.
Solution 2:[2]
At initial the JSON-server must be started from the root folder. ex : if you are using VS code editor click on the folder that consist the data in JSON format and right click on that folder and open it in integrated terminal and try : > json-server --watch db.json and it will be working fine.
In case of directly calling the Json-server, it will initialise the default data on localhost:3000
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Denis |
| Solution 2 | kartik |
