gpt4 book ai didi

javascript - ember.js 错误 : Assertion Failed: The response from a findAll must be an Array, 未定义

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:39 26 4
gpt4 key购买 nike

也许这是有史以来最愚蠢的问题,但仍然是 - 如何手动查询服务器以获取特定模型的记录?

App.UrlNewRoute = Ember.Route.extend({
setupController: function(controller, model) {
console.dir(1);
this.store.find('UrlType').then(function(url_types) {
controller.set('urlTypes',url_types);
});
}
});

{"url_types":[{"id":1,"caption":"text link"},{"id":2,"caption":"guest post"},{"id":3,"caption":"blog comment"},{"id":4,"caption":"banner"},{"id":5,"caption":"profile"},{"id":6,"caption":"review"}]}

最佳答案

完全合理的问题,

您应该使用 camelCase 查询它:

this.store.find('urlType')

并且您的 json key 也应该是 camelCase(您也可以使用序列化程序来修复它):

{
"urlTypes":[
{
"id":1,
"caption":"text link"
},
{
"id":2,
"caption":"guest post"
},
{
"id":3,
"caption":"blog comment"
},
{
"id":4,
"caption":"banner"
},
{
"id":5,
"caption":"profile"
},
{
"id":6,
"caption":"review"
}
]
}

http://emberjs.jsbin.com/OxIDiVU/301/edit

关于javascript - ember.js 错误 : Assertion Failed: The response from a findAll must be an Array, 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22560929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com