Async function returns [object Promise]

后端 未结 2 572
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 16:14

I\'m trying to return an async function but I either get promise: < { PENDING } > or [object Promise] instead of [object Object]

2条回答
  •  礼貌的吻别
    2021-01-28 16:34

    I solved this by adding an await to the top level getNext() aka

    const next = await getNext({
      page,
      value,
      name,
      id,
    });
    

    which is inside an async router.post call. So the answer is: make sure all functions are async all the way to the top so that they wait for eachother.

提交回复
热议问题