【发布时间】:2016-03-06 12:08:58
【问题描述】:
我需要弄清楚如何将完整的 JSON 响应打印到我的页面(甚至是部分页面)上,但我似乎无法弄清楚。稍后我将最终用更多上下文填写页面。
JS 文件:
app.get('/', function(req, res) {
var context
apiLib.fetch('acct:chars', function(err, result){
if(err) throw err
context = result;
console.log(result);
res.render('/', context);
});
});
车把:
{{#each context.characters}}
{{this.name}}
{{/each}}
JSON 数据:
{
"result": {
'1234':{ //this is the character ID
"characters": {
"name": 'Daniel',
"CharacterID": '1234'
etc...
}
}
}
我的页面什么也没打印,但控制台记录了所有内容。我正在使用 express.js 来处理路由。
【问题讨论】:
-
删除
this中的this.name。
标签: javascript json node.js express handlebars.js