I don't understand why i can't save my callback response in the global state var that i defined above. I store it in the response, but when i called it outside it always return undefined.
const state = {}    
    const initInfos = async () => {
        try {
                chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
                const message = {
                    name: 'loadInfos',
                    params: tabs[0]
                };
                Message.send(message, (res) => {
                    state.result = res.data; // store data in state.result
                     console.log(state.result) // display response from message
                });
            });
        }
        catch (e) {
            console.error(`error ${e}`);
        }
    };
    const controller = async () => {
        await initInfos();
        console.log(state.result); //display undefined
    };
    ['hashchange', 'load'].forEach((e) => window.addEventListener(e, controller));
