I am new at JS programming but I am trying to write an extension that gets cookies for specific domains and processes them when a button is clicked. I am trying to use promises/await but the code does not seem to wait till the promise is resolved.
async function getCookies(domain) {
    let promise = new Promise((resolve, reject) => {
        chrome.cookies.getAll({"domain": domain}, function(cookies) {
            resolve(cookies);
        });
    });
    let cookies = await promise
    return cookies;
}
document.addEventListener('DOMContentLoaded', function() {
    var link = document.getElementById('btnremove');  
    link.addEventListener('click', function() {
        var domains = ["www.horizonhobby.com", "yolo.com", "rcgroups.com", "yotpo.com"];
        domains.forEach(domain => {
            let cookies = getCookies(domain);
            console.log("Got " + cookies.length + " cookies for " +  domain);
      });
    });
});
My console log message gets called before the cookies are returned from the API. Looking in DEVTools cookies is defined as:
cookies: Promise proto: Promise [[PromiseState]]: "pending" [[PromiseResult]]: undefined
