javascript - json-server 未显示 JSON 数据的 URL
问题描述
我正在与json-server
. 我已经安装它npm install -g json-server
并正在观看使用
json-server --watch db.json
我db.json
在 app 文件夹中添加了包含以下数据的文件
{
"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"
}
]
}
但只有http://localhost:3000/
工作。表明
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
不管用。我该如何解决这个问题?
解决方案
第一次尝试运行json-server
时,如果找不到提供的源代码,则会load.js
为您写出默认示例:
> 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
在随后的运行中,由于文件现在存在,服务器似乎启动得很好,但没有使用db.json
您认为的文件。出于这个原因,这似乎有点错误,我已经打开了一个 PR要求明确要求这种行为。
推荐阅读
- mysql - 使用连接或子查询进行搜索
- angular - 如何从 Angular http://localhost:4200 端口进行 Graph API 调用?
- android - 如何在kotlin中将会话ID从活动调用到片段?
- c++ - 将结构向量的元素打印到文件
- dataweave - 根据其值组合有 4 个字段,我们必须在 Mulesoft 中过滤数据
- ionic-framework - 如何将我的 URL 与我的 MYSQL 中的数据结合起来
- kubernetes - 在 EKS 上创建 Istio IngrressGateway 时出现“密钥重复条目”错误
- sql - 如何根据表的元数据获取SQL中多个表的内容?
- angular - Angular:从 FormControl 获取所有验证器的列表
- python - Python,不一致的zip文件提取