How to run a request in a function in Nodejs?

I have the following code to run a request and return the result in NodeJS :

const https = require('https')

async function GetStatus(HostName, Path) {  
    const options = {hostname: HostName,port: 443,path: Path,method: 'GET'}                     
    const req = https.request(options, res => {     
        res.on('data', d => {
            var result = JSON.parse(d);
            console.log('A - the status is ' + result.status);
            return result.status;               
        })
    })
    
    req.on('error', error => {console.error(error)});
    req.end();  
}

async function T() {
    var x = await GetStatus('www.domain.com', '/path');     
    console.log('B - The status is ' + x);
}

T();

I’m trying to run the function GetStatus to get some results based on the https request.

When running this code, I’m getting A – The status is something while the output of the function is B – The status is undefined

Does anyone know how to solve that please ? such that the function returns the result as expected instead of undefined.

Thanks.
Regards,