Twitch viewer: Need help with online/offline function

I’m working on my Twitch project, but I still have one problem with my script. I’m having problems with a function I created to determine whether a user is online or not. This function is connected to an if/else statement and has been labeling all the users as offline. It almost seems like the function is not working at all Can someone tell me what I’m doing wrong or how I can improve.

function online(user) {
    var url = 'https://wind-bow.glitch.me/twitch-api/streams/' + user;
    var request = new XMLHttpRequest();
    request.open('GET', url);
    request.responseType ='json';
    request.send();
    var bool;
    request.onload = function () {
        if (request.response.stream === null) {
            bool = false;
        } else {
            bool = true;
        }   
    };
    
    return bool;
}

Thank you for the tip, it’s helping me along with what to do next. Good job at noticing how I used the if statement. Just changed up the structure, and I’m all set, thanks for the help!