There's a value I need to obtain asynchronously and have no other way around it. Now I can get this value as follows with the getValue function:
const getValue = async () => {
var result = await someObject.someFunction();
console.log(result);
return result;
}
const data = getValue();
const iWantToUseThis = `some-${data}-files`;
The console.log shows the correct value but the problem is that when I try to use the obtained value oustide the async function it shows as [object Promise]. Is there any way around this? I also tried with then but my defined variables are not usable oustide the then function.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment