Declaring a function async
means that it will return the Promise
. To turn the Promise
into a value, you have two options.
The "normal" option is to use then()
on it:
getSSID().then(value => console.log(value));
You can also use await
on the function:
const value = await getSSID();
The catch with using await
is it too must be inside of an async
function.
At some point, you'll have something at the top level, which can either use the first option, or can be a self-calling function like this:
((async () => {
const value = await getSSID();
console.log(value);
})()).catch(console.error):
If you go with that, be sure to have a catch()
on that function to catch any otherwise uncaught exceptions.
You can't use await
at the top-level.