Can't get current logged user before page load

I can’t get the logged in address string even if there is a logged in wallet
here’s the code=

window.onload = async () => {

        if(account==id){

        const options2 = {

            chain: "matic",

            address: "0x4Ca23e9584cC784814180fCF08f72B5d94ca5379",

            function_name: "GetactiveFundme",

            abi: ABI,

            params: { _user: id },

        };

        var dd;

        fetch({ params: options2 })

            .then((response) => response)

            .then((data) => {

                dd = JSON.stringify(data);

                if (dd == "true") {

                    console.log("true");

                    bSetButton("hidden");

                }

                if (dd == "false") {

                    console.log("false");

                    bSetButton("visible");

                }

            });

        var temp = await fetchTokenPrice();

        temp = Number(temp).toFixed(2);

        changeprice(temp);

    };

}

I’m not seeing where you’re trying to get the current wallet’s address in this code. I think any wallet injections (window.ethereum) and updates of the current Moralis user state (from localStorage) happen after window.onload.