2016-02-20 68 views
0

我是Ember的新手,正试图使用​​beta 2.3.0版本创建一个小应用程序。Ember Serializer适用于Mirage,但不适用于真实数据

提供了一个国家和邮政编码,我想获得城市和邮政编码。 使用幻影和自定义序列化程序(我使用的是与真正的json相同的格式)我的代码完美工作。

但是,凭借真实的API,Promise仍处于Pending状态。控制台中没有错误。 当使用真正的服务指示序列化程序没有执行时,我的序列化程序中的日志不显示。 有没有人遇到过类似的问题。请帮忙。

在我的控制,我发现记录为:

this.store.find('address', zipcode).then(
       function(address) { 
        console.log("Hello Got Address"); 
}); 

我的适配器/ application.js中:

export default DS.RESTAdapter.extend({ 
host: 'http://real_url_here', 

pathForType: function(type) { 
     return ''; 
}}); 

的JSONAPISerialier在串行器/ application.js中被重写为:

export default DS.JSONAPISerializer.extend({ 

normalizeResponse(store, primaryModelClass, payload, id, requestType) { 

.......... // Code goes here 
}}); 

在我的mirage/config.js中,我返回了2个zip代码的示例json,并在最后添加了:

this.passthrough('http://real_url_here/**'); 

调用真正的服务,为其他邮编

+0

请添加一些示例代码。 – Shayan

回答

0

我得到了答案终于:)。

我不得不停用发展的幻象:

要禁用的发展,

// config/environment.js 
... 
if (environment === 'development') { 
     ENV['ember-cli-mirage'] = { 
     enabled: false 
}} 
相关问题