我正在使用Ember-cli-mirage来模拟数据 . 我想慢慢整合位于我本地机器上的 生产环境 API的部分http://localhost:8000 . Ember docs tell me我应该能够设置适配器,这样我就可以为每个模型设置不同的主机 .
我有一个 customer
模型,并设置了成功提供数据的ember-cli-mirage . 客户模型是我想要拆分为localhost:8000的第一个模型 .
我用以下方法设置了adapter / customer.js:
import DS from 'ember-data';
export default DS.RESTAdapter.extend( {
host: 'http://localhost:8000',
namespace: 'api/v1'
});
但是当我拨打电话时,我收到了一个错误:
Mirage: Error: Your Ember app tried to GET 'http://localhost:8000/api/v1/customers',
but there was no route defined to handle this request.
Define a route that matches this path in your
mirage/config.js file. Did you forget to add your namespace?
我的 Headers 检查员显示客户正在向海市蜃楼服务器发出请求:
Request URL:http://localhost:6543/customers
Request Method:GET
Status Code:304 Not Modified
Remote Address:[::1]:6543
我怀疑's something to do with my config/environment.js setup so I'正在寻找https://github.com/samselikoff/ember-cli-mirage/issues/497#issuecomment-183458721的变体作为潜在的解决方法 . 但我可以't see why mirage won' t接受适配器覆盖 .
1 回答
应该通过海市蜃楼文档回读这个 . 有一个passthrough function允许海市蜃楼通过某些请求通过Ember绕过海市蜃楼:
为了在我的应用程序适配器中工作,我添加了:
如果这有助于您以任何方式随意给这个答案一个upvote :)