我使用燼數據,我打電話給使用承諾的空白內容?
this.store.findAll('environment').then(function(values){
//1
},function(reason){
//rejected
});
我的API和我的代碼不會進入// 1,問題是,我得到這個對象,似乎是相當無效的。
這裏是我的API發回。
{
"data": {
"environments": [
{
"id": 1,
"localePath": "C:\\XML_DEPOT",
"name": "Acceptation 1",
"remotePath": "D:\\XML_DEPOT",
"databaseServerName": "blabla",
"databaseName": "blabla",
"port": 60903
},
{
"id": 2,
"localePath": "bob",
"name": "Acceptation 2",
"remotePath": "bob",
"databaseServerName": "blabla\\blabla",
"databaseName": "blabla",
"port": 60904
}
]
}
}
第二次嘗試我給了它,但仍然不喜歡它。
{
"data": [
{
"id": 1,
"localePath": "C:\\XML_DEPOT",
"name": "Acceptation 1",
"remotePath": "D:\\XML_DEPOT",
"databaseServerName": "W050A01SQL1",
"databaseName": "MAMROT01P1_MSCRM",
"port": 60903,
"type": "environments"
},
{
"id": 2,
"localePath": "bob",
"name": "Acceptation 2",
"remotePath": "bob",
"databaseServerName": "W050A01SQL1\\W050A01SQL1B02",
"databaseName": "MAMROT01P1_MSCRM",
"port": 60904,
"type": "environments"
}
]
}
這是我的模型聲明
//environment.js
export default Model.extend({
id: DS.attr('number'),
localePath: DS.attr('string'),
name: DS.attr('string'),
remotePath: DS.attr('string'),
databaseServerName: DS.attr('string'),
databaseName: DS.attr('string'),
port: DS.attr('number')
});
謝謝!
答案:將「數據」更改爲「環境」並刪除模型中的ID –
是的,假定爲「id」。恭喜你弄明白了! –