Store.push(類型,數據)已被棄用。請提供一個JSON-API文檔對象作爲store.push的第一個也是唯一的參數自從升級到Ember 1.13.2和Ember數據後,Ember JS棄用錯誤1.13.3
我剛剛更新爲ember 1.13.2和ember-data 1.13.3,現在我收到大量的棄用消息在這篇文章的標題中提到。我不知道是什麼導致它出現,並且Ember Inspector的Deprecations選項卡不會顯示我的代碼中問題所在的位置。
如果有人能向我解釋信息的含義以及我需要做些什麼來解決它,我將不勝感激。
謝謝。
UPDATE:
我的自定義應用程序接口看起來是這樣的:
// app/adapters/application.js
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
host: 'http://dev.mydomain.com',
namespace: 'api/v1',
});
它使用ActiveModelAdapter附加爲不同的過時消息解釋說,ActiveModelAdapter將不再與Ember數據捆綁自v2.0.0起。但是,我已經使用ember-data適配器和add來試用我的代碼,並且獲得了有關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)
新的錯誤之後增加isNewSerailizerAPI:真實串行器(參見答案):
Error while processing route: elavonApplication.index Cannot read property 'id' of undefined TypeError: Cannot read property 'id' of undefined
at ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83482:33)
at Ember.Mixin.create._extractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83349:98)
at null.<anonymous> (http://localhost:4200/assets/vendor.js:83419:19)
at http://localhost:4200/assets/vendor.js:84310:20
at Map.forEach.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:84309:83)
at ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83413:17)
at Ember.Mixin.create._extractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83265:96)
從服務器返回的JSON確實包含「id」字段,但序列化程序似乎無法找到它,因爲我們收到錯誤並且模型未填充到Ember存儲區。
失敗行是:
// assets/vendor.js
var belongsTo = { id: data.id, type: data.type };
,並把手錶上的「數據」變量,其中的「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捆綁-data作爲建議的早期棄用消息。不知道這個附加組件在所有最近的更新之後是否與ember-data不兼容? (通過恢復到原始的捆綁適配器進行測試,仍然發生同樣的錯誤)。
您是否有任何自定義適配器? –
感謝您的快速響應!是的,我有一個自定義適配器,因爲我使用ActiveRecordAdapter。我已更新我的帖子以顯示適配器。 – danr1979
您是否可以在開發人員控制檯中包含此棄用的堆棧跟蹤?這將有所幫助。 –