【发布时间】:2019-10-27 22:56:03
【问题描述】:
当我将此函数作为回调 [object Promise] 运行时,为什么我会变成这样?我使用 Mitivit4min (Github) 的 Ts3 nodejs 框架
这里我尝试了一些代码(返回值 = [object Promise])
async function getChannelName(cid) {
await teamspeak.getChannelByID(cid).then(data => {
return data.name;
});
};
如何将此值转换为具有“我的酷频道”之类值的字符串
最好的问候
【问题讨论】:
-
你没有返回等待的结果,你在不必要地混合
await和.then。 -
不要混淆
async-await和Promise.then@F.Ghost 使用const data = await teamspeak.getChannelByID(cid)
标签: javascript node.js asynchronous teamspeak