why do i become when i run this function as callback [object Promise] ? i use the Ts3 nodejs framework by Miltivit4min (Github)
here some code i tried (return value = [object Promise])
async function getChannelName(cid) {
await teamspeak.getChannelByID(cid).then(data => {
return data.name;
});
};
how can i convert this value to a string with a value like "My cool Channel"
best regards
An async
function always returns a Promise
by design and your getChannelName
function has no return statement, so the promise is never resolved. Also you are mixing up some await
and .then()
syntax, you only need one of them.
async function getChannelName(cid) {
const data = await teamspeak.getChannelByID(cid);
return data.name;
};
const name = await getChannelName(123); // name has the channel name