command的同步callback中如何处理异步方法? #1416
Answered
by
shigma
little-creeper
asked this question in
Q&A
-
I'm new to ts. 如图,getServerStatus()方法返回一个Promise(因为这个方法内部涉及到http请求),我理应在前面加上await获取到Server[],但action的callback不能返回一个Promise。 |
Beta Was this translation helpful? Give feedback.
Answered by
shigma
Jul 16, 2024
Replies: 1 comment
-
command 的 action 是异步的,加个 async 即可。 .action(async () => {
await getServerStatus()
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
little-creeper
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
command 的 action 是异步的,加个 async 即可。