'Why is my Suitelet returning Undefined response

I am sending a request to a suitelet to return whether or not a file exist in the file cabinet. Everything seems to work fine on the server side however when I get to the clientscript the I am getting, and undefined object returned.

Suitelet:

function onRequest(context) {

    if (context.request.method === 'GET') {
        var requestParam = context.request.parameters;
        var fileName = 'Drag and Drop/Sales Order/' + requestParam.msgBoxValue + '.pdf';
        var contextResponse = 'true';
  
    function fileExist(fileId){
        if (typeof fileId == 'undefined'){
        return 'false';
        }
        if (fileId === null){
        return 'false';
        }
        if (fileId === ''){
        return 'false';
        }
    return 'true';
    }

    try{
        file = file.load({id: fileName});
        contextResponse = fileExist(file);
    } catch (e) {
        log.error({
        title: e.name,
        details: e.message});
        }
    };
  
  return context.response.write(contextResponse);
}

return {
    onRequest: onRequest
};

});

ClientScript:

     function checkIfFileExists() {
            //call suitelet
            var suiteletURL = url.resolveScript({
                scriptId:'customscript_suitelet_checkiffileexist',
                deploymentId: 'customdeploy_suitelet_checkiffileexist',
                returnExternalURL: false,
                params: {
                   'msgBoxValue':msgBoxValue
                }
            });

            https.get.promise({
                url: suiteletURL
            }).then(function (response) {
               console.log('response = ' + response)
            }).catch(function (reason) {
               console.log('reason = ' + reason)
            });
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source