Proper way to perform a helix API call Using JavaScript

Found out my problem. : Javascript is weird, and returning data to parent routines is confusing AF.

So the ‘fetch’ function I call is in and of itself a function. So by ‘returning’ inside the “.then” statement was purely returning the variable to the ‘CallAPI’ function. Call API was never returning anything to its parent routine. I tried doing what some help guides said (’Return Fetch’) but that didnt work at all, I couldn’t chain it into the .then routines. I also couldn’t return it as a boolean true/false, I had to put that into quotes to make it strings. But it will work for what I need it to.

Here is updated working code:

async function APICall(URL, HeadersObject) {
  // Perform API Call and return a JSON object
  document.write("<br> Performing API Call to URL: " + URL)
  var resp = await   fetch( URL ,   { headers: HeadersObject   } )
  var D = resp.json()
  if (D.error) {
        return "ERROR"
  	}else {
	    return D
  	}	
};  
 
 async function CheckStreamerOnline(ChannelURL) {
  var bolONLINE = false;
  if (ChannelURL ===  'NoValueSet' || ChannelURL ===  '' || ChannelURL ==  null ) {  
  // No Value -> Ignore
  bolOnline = false; 
  } else { 
  	//Perform API check to determine if the specific channel is online
	var myHeaders = new Headers(); // Currently empty
	myHeaders.append("Client-ID", AppClientID)
	myHeaders.append("Authorization", "Bearer " + ApiToken)

	var Resp = await APICall(StreamsURL + 'user_login=' + ChannelURL, myHeaders);
  	if (Resp.data[0]){
    	bolONLINE =  "TRUE"
    }else {
    	bolONLINE = "FALSE"         
    }
    
  };   // end of large if statement    
	return bolONLINE
 };