怎么解决Promise { <pending> }?

风青杨明 2018-10-13 15:34:51 104阅读 举报

router.get("test", async ctx => {
let q = await ctx.db
.execute(SELECT w.create_time as create_time,w.camera_id,w.status, w.problem_type_id,w.repair_user_id,w.no as no,wp.pic_url FROM work_flow w left OUTER JOIN work_flow_pic wp ON w.no=wp.flow_id);
let data = q.map(item => {
let url = ctx.db.execute(
select * from work_flow_pic where flow_id=${item.no}
);
return {
create_time: item.create_time,
no: item.no,
url: url.then(function(result) {
result;
})
};
});
console.log(data);
let retstr = [{"ret":"0"}];
await ctx.render("interface_ret", {
retstr
});
});
运行后的结果是:
[ { create_time: 2018-10-09T02:47:54.000Z,
no: '153905327352986',
url: Promise { <pending> } },
{ create_time: 2018-10-09T02:47:54.000Z,
no: '153905327352986',
url: Promise { <pending> } },
{ create_time: 2018-10-09T08:51:33.000Z,
no: '153905327352987',
url: Promise { <pending> } } ]

0 条解答
最新解答
暂无评论

赶紧努力消灭 0 回复