After running the code below I get undefined in the console.log.
I am attempting to return a resolved Promise but it fails. There are no errors.
The console output is: getData(): undefined
Can anyone spot my issue?
function getData(){
var url = 'https://pigfox.com/api/v1/test';
https.get(url, res => {
res.setEncoding("utf8");
res.on('data', data => {
return new Promise(resolve => {
resolve(data);
});
});
});
}
async function go(){
var rs = await getData();
console.log('getData(): ' + rs);
}
go();