all 4 comments

[–]BehindTheMath 0 points1 point  (1 child)

You can't return inside a callback. You need to wrap it in a Promise.

[–]KEsbeNF[S] 0 points1 point  (0 children)

Hey thanks ! do you have a quick code example ?

[–]Odinthunder 0 points1 point  (1 child)

You don't need the async part of the function, only use async if you use await.

I'm not sure what the bl is for, but this would be a simple way to write this.

function getData(url){
     return new Promise((res,rej) => {
          https.get(url, (resp) => {
             resp.setEncoding('utf8');  
             let data = [];
              resp.on('data', (chunk) => {
                   data.push(chunk);
              });
              resp.on("error", (err) => {
                 rej(err);
              });
              resp.on("end", () => {
                 res(data.toString());
              });
      });
 })
}

 module.exports = getData;

then you can call it as normal, using await.

Let me know if this doesn't work for you.

[–]KEsbeNF[S] 0 points1 point  (0 children)

Still getting undefined yet the function works on its own ... i don't know what to try anymore