我使用pg-promise,并尝试向用户模型中的数据库发出请求,以获取所有用户的数组,如下所示: let users// in debug mode data is my expected array return users;但是当我从控制器发出get请求时,它返回promise Promise { <pending> },而不是我期望<
我无法在抛出await is only valid in async function错误的'new Promise‘块中使用async/await。我甚至不知道这是否可能,但我需要使用它或一种方式来实现我想要的。这是我想要做的: 用户输入一个查询,它将通过一个名为doesExist的recursive function。我必须使用递归函数,因为API并不总是为查询提供数据。递归
我正在探索Promise.all()的用法,但我不知道为什么它没有给我带来预期的结果。我试着一步一步地说明这一点。');
// to simulate a api call that will response after 5 secundefine], but I expect [3, 1337, 1000]
apiCall().then((response)=>{console.log(res