我得到這個typeerror在我的迴應,我不知道,什麼格式store.find('someThread')期望。 這裏是我燼部分:貓鼬&餘燼,記錄被拒絕的原因:typeerror
App.RestAdapter = DS.RESTAdapter.extend({
url: 'http://mylocalhost:3000',
namespace: 'api',
serializer: DS.RESTSerializer.extend({
primaryKey: function(type) {
return '_id';
}
})
});
App.Store = DS.Store.extend({
revision: 12,
adapter: App.RestAdapter
});
App.VideoRoute = Ember.Route.extend({
model: function() {
console.log("video..", this.store.find('video'));
return true;
}
});
而這裏的節點部分:
exports.list = function(req, res) {
Video.find(function(err, videos) {
var payload = { video: {name: "sampleName"}};
return res.send(200, JSON.stringify(payload));
});
}
這裏是響應的console.log:
Class {constructor: function, reason: null, isPending: undefined, isSettled: undefined, isRejected: false…}
__ember1385638132476: undefined
__ember1385638132476_meta: Meta
_super: undefined
arrangedContent: (...)
content: (...)
isRejected: true
reason: TypeError
message: "Object function() {↵ if (!wasApplied) {↵ (...)"
stack: (...)
get stack: function() { [native code] }
set stack: function() { [native code] }
__proto__: Error
__proto__: Object
如果我只是發送一個字符串,我會得到一個響應:`` res.send( 「東西」); 但這只是在responseText和isRejected是真的,所以...
任何想法?
UPDATE
* 這裏是截斷的消息部分:*
"Object function() {
if (!wasApplied) {
Class.proto(); // prepare prototype...
}
o_defineProperty(this, GUID_KEY, undefinedDescriptor);
o_defineProperty(this, '_super', undefinedDescriptor);
var m = meta(this), proto = m.proto;
m.proto = this;
if (initMixins) {
// capture locally so we can clear the closed over variable
var mixins = initMixins;
initMixins = null;
this.reopen.apply(this, mixins);
}
if (initProperties) {
// capture locally so we can clear the closed over variable
var props = initProperties;
initProperties = null;
var concatenatedProperties = this.concatenatedProperties;
for (var i = 0, l = props.length; i < l; i++) {
var properties = props[i];
Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Ember.Mixin));
if (properties === null || typeof properties !== 'object') {
Ember.assert("Ember.Object.create only accepts objects.");
continue;
}
var keyNames = Ember.keys(properties);
for (var j = 0, ll = keyNames.length; j < ll; j++) {
var keyName = keyNames[j];
if (!properties.hasOwnProperty(keyName)) { continue; }
var value = properties[keyName],
IS_BINDING = Ember.IS_BINDING;
if (IS_BINDING.test(keyName)) {
var bindings = m.bindings;
if (!bindings) {
bindings = m.bindings = {};
} else if (!m.hasOwnProperty('bindings')) {
bindings = m.bindings = o_create(m.bindings);
}
bindings[keyName] = value;
}
var desc = m.descs[keyName];
Ember.assert("Ember.Object.create no longer supports defining computed properties.", !(value instanceof Ember.ComputedProperty));
Ember.assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
Ember.assert("`actions` must be provided at extend time, not at create time, when Ember.ActionHandler is used (i.e. views, controllers & routes).", !((keyName === 'actions') && Ember.ActionHandler.detect(this)));
if (concatenatedProperties && indexOf(concatenatedProperties, keyName) >= 0) {
var baseValue = this[keyName];
if (baseValue) {
if ('function' === typeof baseValue.concat) {
value = baseValue.concat(value);
} else {
value = Ember.makeArray(baseValue).concat(value);
}
} else {
value = Ember.makeArray(value);
}
}
if (desc) {
desc.set(this, keyName, value);
} else {
if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
this.setUnknownProperty(keyName, value);
} else if (MANDATORY_SETTER) {
Ember.defineProperty(this, keyName, null, value); // setup mandatory setter
} else {
this[keyName] = value;
}
}
}
}
}
finishPartial(this, m);
this.init.apply(this, arguments);
m.proto = proto;
finishChains(this);
sendEvent(this, "init");
} has no method 'extract'"
UPDATE2:發現你可以覆蓋Ajax的方法
。現在,至少我知道,那JSON是beeing上的成功,功能傳送,但數據屬性仍然是不確定的...
App.ApplicationAdapter = DS.RESTAdapter.extend({
url: 'http://localhost:3000',
namespace: 'api',
ajax: function(url, type, hash) {
var adapter;
adapter = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
var headers;
hash = hash || {};
hash.url = url;
hash.type = type;
hash.dataType = "json";
hash.context = adapter;
if (hash.data && type == "GET") {
hash.contentType = "application/json; charset=utf-8";
hash.data = JSON.stringify(hash.data);
}
if (adapter.headers !== undefined) {
headers = adapter.headers;
hash.beforeSend = function(xhr) {
return forEach.call(Ember.keys(headers), function(key) {
return xhr.setRequestHeader(key, headers[key]);
});
};
}
hash.success = function(json) {
console.log("success", hash.data, json); //-> undefined, Object {video: Object}
return Ember.run(null, resolve, json);
};
hash.error = function(jqXHR, textStatus, errorThrown) {
return Ember.run(null, reject, adapter.ajaxError(jqXHR));
};
return Ember.$.ajax(hash);
});
},
});
能的變化你顯示出現在'message'屬性中的內容。你的堆棧跟蹤顯示它可能被截斷,可能是消息show'「Object function(){if(!wasApplied){↵...沒有方法foo」等。這可能會有所幫助。 –
thx @MárcioRodriguesCorreaJúnior,更新了帖子。我不得不說,我是這個後端的新手。我通常工作沒有燼數據。 – user3045673
什麼是你的餘燼數據版本? –