I'm trying to use async/await function following some tutorials but I don't know why always returns
Promise { <pending> }
Here is my code:
function doubleAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
console.log(x);
resolve(x * 2);
}, 2000);
});
}
async function get_media_async (media_id) {
const a = await doubleAfter2Seconds(10);
return a;
}
exports.get_media = function(media_id){
var media_url = get_media_async(media_id);
return media_url;
};
Any help would be appreciated!