How to solve the problem of Promise { <pending> }?

How to solve the problem of Promise { <pending> }?
0

#1

Here is my code:

Blockquote

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
  });
});

When I run the code I get this output:

Blockquote

   [ { 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> } } ]

I don’t know how to solve it


#2

You can try this:

url: url.then(function(result) {
    return result;
     })

Seems weird to me, but since you return nothing from the anonymous function url result as a pending Promise i guess^^