Ember.js 自升级到Ember 1.13.2和Ember Data 1.13.3后,Ember JS弃用错误

Ember.js 自升级到Ember 1.13.2和Ember Data 1.13.3后,Ember JS弃用错误,ember.js,ember-data,ember-cli,Ember.js,Ember Data,Ember Cli,Store.push(类型、数据)已被弃用。请提供JSON-API文档对象作为store.push的第一个也是唯一一个参数 我刚刚更新到了ember 1.13.2和ember data 1.13.3,现在我收到了很多在这篇文章标题中提到的反对信息。我不知道是什么原因导致它出现,而且Ember Inspector的Deprecations选项卡没有显示问题在代码中的位置 如果有人能向我解释这条信息的含义以及我需要做些什么来解决它,我将不胜感激 谢谢 更新: 我的自定义应用程序适配器如下所示: //

Store.push(类型、数据)已被弃用。请提供JSON-API文档对象作为store.push的第一个也是唯一一个参数

我刚刚更新到了ember 1.13.2和ember data 1.13.3,现在我收到了很多在这篇文章标题中提到的反对信息。我不知道是什么原因导致它出现,而且Ember Inspector的Deprecations选项卡没有显示问题在代码中的位置

如果有人能向我解释这条信息的含义以及我需要做些什么来解决它,我将不胜感激

谢谢

更新:

我的自定义应用程序适配器如下所示:

// app/adapters/application.js
import ActiveModelAdapter from 'active-model-adapter';

export default ActiveModelAdapter.extend({
    host: 'http://dev.mydomain.com',
    namespace: 'api/v1',
});
它使用ActiveModelAdapter附加组件作为不同的弃用消息,解释说从v2.0.0起ActiveModelAdapter将不再与ember数据捆绑在一起。但是,我已经用ember数据适配器和加载项尝试了我的代码,得到了关于Store.push的相同的不推荐消息

由于存在多个版本的相同弃用,因此存在一些堆栈跟踪,但以下是几个:

DEPRECATION: store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.
    at ember$data$lib$system$store$$Service.extend.push (http://localhost:4200/assets/vendor.js:81014:17)
    at http://localhost:4200/assets/vendor.js:83253:17
    at Array.forEach (native)
    at Ember.Mixin.create._extractEmbeddedHasMany (http://localhost:4200/assets/vendor.js:83251:68)
    at null.<anonymous> (http://localhost:4200/assets/vendor.js:83219:22)
    at http://localhost:4200/assets/vendor.js:84254:20
    at cb (http://localhost:4200/assets/vendor.js:27380:11)
    at OrderedSet.forEach (http://localhost:4200/assets/vendor.js:27163:11)
    at Map.forEach (http://localhost:4200/assets/vendor.js:27384:18)

DEPRECATION: store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.
    at ember$data$lib$system$store$$Service.extend.push (http://localhost:4200/assets/vendor.js:81014:17)
    at Ember.Mixin.create._extractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83302:15)
    at null.<anonymous> (http://localhost:4200/assets/vendor.js:83226:22)
    at http://localhost:4200/assets/vendor.js:84254:20
    at cb (http://localhost:4200/assets/vendor.js:27380:11)
    at OrderedSet.forEach (http://localhost:4200/assets/vendor.js:27163:11)
    at Map.forEach (http://localhost:4200/assets/vendor.js:27384:18)
    at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (http://localhost:4200/assets/vendor.js:84253:83)
    at Ember.Mixin.create._extractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83212:19)
在对“数据”变量进行监视后,在“id”被查找的地方,它是“未定义的”。“数据”变量在代码中定义为:

var data = _normalizeEmbeddedRelationship2.data;
所以,考虑到最近所有余烬数据的变化,我不知道这是否提供了任何线索

我还有一个可能与以下问题有关的反对意见:

Ember Inspector (Deprecation Trace): Your custom serializer uses the old version of the Serializer API, with `extract` hooks. Please upgrade your serializers to the new Serializer API using `normalizeResponse` hooks instead.
at ember$data$lib$system$store$serializer$response$$normalizeResponseHelper (http://localhost:4200/assets/vendor.js:74034:15)
    at http://localhost:4200/assets/vendor.js:75772:25
    at Object.Backburner.run (http://localhost:4200/assets/vendor.js:10776:25)
    at ember$data$lib$system$store$$Service.extend._adapterRun (http://localhost:4200/assets/vendor.js:81352:33)
    at http://localhost:4200/assets/vendor.js:75771:15
    at tryCatch (http://localhost:4200/assets/vendor.js:65295:14)
    at invokeCallback (http://localhost:4200/assets/vendor.js:65310:15)
    at publish (http://localhost:4200/assets/vendor.js:65278:9)
    at http://localhost:4200/assets/vendor.js:42094:7
另外,重申一下,我现在使用的是活动模型适配器插件,而不是早期推荐的与ember数据捆绑在一起的插件。不确定在最近对其进行了所有更新之后,此加载项是否与余烬数据不兼容?(刚刚通过恢复到原始捆绑适配器进行了测试,仍然会发生相同的错误)。

如果设置:

isNewSerializerAPI:true


在您的serialiser上,它应该可以解决这个问题。

好的,最近的ember data 1.13.4更新似乎已经解决了这个问题。一旦我删除了先前尝试的修复程序,即使用:

isNewSerializerAPI: true
在序列化程序上(这导致了其他问题),并更新为1.13.4,一切都正常工作

感谢您提供的帮助。

Per现在push()将JSON API兼容的负载作为唯一参数。过去传递给push的类型是JSON API格式,因此不再需要单独使用。要使这项工作“开箱即用”,您的API源必须返回有效的JSON数据


如果不可能,则需要一个自定义序列化程序来实现转换方法,将API的JSON格式转换为JSON API格式。我认为您可以在序列化程序中的“normalizeResponse”中实现这一点。可以找到从旧序列化程序API转换为新序列化程序API的详细信息

您有自定义适配器吗?感谢您的快速响应!是的,我有一个自定义适配器,因为我使用ActiveRecordAdapter。我已经更新了我的帖子以显示适配器。您可以从开发人员控制台包含此弃用的堆栈跟踪吗?这会有帮助的。好的,我添加了一些堆栈跟踪,因为有多个相同的弃用实例。谢谢。即使使用
isNewSerializerAPI:true
,我也会收到相同的消息。设置此属性后,能否提供错误的堆栈跟踪?还是完全一样?您还可以提供一个JSBin吗?我现在得到一个不同的错误,尽管我现在已经更新到了ember data 1.13.4(昨天发布),但仍然存在。我已将错误及其堆栈跟踪添加到原始帖子的底部。
Ember Inspector (Deprecation Trace): Your custom serializer uses the old version of the Serializer API, with `extract` hooks. Please upgrade your serializers to the new Serializer API using `normalizeResponse` hooks instead.
at ember$data$lib$system$store$serializer$response$$normalizeResponseHelper (http://localhost:4200/assets/vendor.js:74034:15)
    at http://localhost:4200/assets/vendor.js:75772:25
    at Object.Backburner.run (http://localhost:4200/assets/vendor.js:10776:25)
    at ember$data$lib$system$store$$Service.extend._adapterRun (http://localhost:4200/assets/vendor.js:81352:33)
    at http://localhost:4200/assets/vendor.js:75771:15
    at tryCatch (http://localhost:4200/assets/vendor.js:65295:14)
    at invokeCallback (http://localhost:4200/assets/vendor.js:65310:15)
    at publish (http://localhost:4200/assets/vendor.js:65278:9)
    at http://localhost:4200/assets/vendor.js:42094:7
isNewSerializerAPI: true