【发布时间】:2017-11-10 08:38:39
【问题描述】:
我正在尝试使用 JSON-server 模拟服务响应。
实际网址为:message-service/notifications?id=xyx
我正在模拟这个 URL 以通过 JSON 服务器访问一个虚拟 URL:
{
"/message-service/notifications?id=:id": "/notifications/:id"
}
我的 Json 对象如下所示:
"notifications": [
{
"id": "xyz",
"getNotificationsResponse":{ }
}
]
问题是 JSON 服务器没有点击虚拟 URL 来获取数据。 此处应进行哪些更改以使 JSON 服务器响应数据?
我在控制台中遇到错误:
Request URL:http://localhost:9081/message-service/notifications?id=xyz
Request Method:GET
Status Code:404 Not Found
【问题讨论】:
-
这不是答案,而是另一种选择。你可以试试beeceptor.com,如果它可以帮助你像 JSON-server 一样模拟。您不应运行本地主机服务器,而是为所有模拟运行托管端点。
标签: javascript api mocking json-server