Return onMessage result

Hi!

I would like to return ‘result.data’ (e.g. line 15) to the scope where callHTML is launched. How can I achieve this?

function callHTML(pref, sref){

**var**  request =  '{'  +  '"pref"' +  ':'  +  '"'  + pref +  '",'  +  '"sref"'  +  ':'  +  '"'  + sref +  '"'  +  '}' ; 
$w( "#html8" ).postMessage(request); 

//Receive message from the HTML element 
$w( "#html8" ).onMessage( 

	**function**  (result) {  // Adds an event handler that runs when the HTML Component sends a message. 
        		console.log(`Incoming message: ${result.data}`); 
	} 
); 

//return result.data 

}

Hi,
What is the use case? what are you trying to achieve?
check out this article about messaging HTML component.

Or