Change WordPress Menu Based on Customer Location with Cloudflare Worker

I am attempting to change the WordPress Menu based on Viewer Location using cloudflare workers. Here is a simple method to do this in functions.php: https://gist.github.com/timersys/1eaa6ed10e2dea0e9a972733acd3ded0

My Goal is to write something similar as such:

    addEventListener('fetch', event => {
        event.passThroughOnException()
        event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest(request) {
        const country = request.cf.country
        if (country != 'US' && country !='CA') {
    
        CHANGE MENU

}

    
        // return modified response
         return new Response(html, response) 
    }