Ember Mirage Fake API 使用 Postman 进行测试

Ember Mirage Fake API test with Postman

我有我的海市蜃楼设置,其中 returns 数据在我定义的模型上,例如,如果我调用 /api/users:它 returns 我需要的所有假用户。如果我接同一个电话并在 Postman 上进行测试,它 returns 什么都没有?我认为 Mirage 的行为就像一个假的 API 端点服务器,用 Postman 测试它就可以了。我在这里遗漏了什么吗?

Mirage 仅在当前浏览器 window 中拦截 AJAX 和获取请求。它正在使用 pretender library therefor, which replaces the native XMLHttpRequest object to achieve that one. This is not affecting any other browser window or addon. Therefore you can't query the mock API using Postman or any other client outside of current window. For the same reason you can't debug the requests in network tab of developer tools. However Mirage could be configured to log intercepted requests to console.