'Asyc function await stops everything, what am I missing?

I have a function that gets called at the end of each loop, but I'm having trouble with the 2nd time around.

async function getData(auth) {
    let sheet = sheetIDGlobal;
    let selectedRow = sheetsRow;
    let sheets = await google.sheets({ version: 'v4', auth });
    console.log("Waiting for Google Sheets reply .....");
    return new Promise((resolve, reject) => {
        sheets.spreadsheets.values.get({
            spreadsheetId: sheet,
            range: selectedRow,
        }, (err, res) => {
            if (err) {
                reject(err);
                console.log('The API returned an error: ' + err);
            }
            const rows = res.data.values;
            if (rows.length) {
                promises = rows.forEach((row) => {
                   // data here
                    console.log(data);
                })
                return Promise.resolve(promises);
            } else {
                console.log('No data found.');
            }
            console.log(rows, "<----rows");
            resolve(rows);
        })
    })
}

Later in the script, I have another function that calls getData(), but the code after it doesn't get run.

async function loadAddContentPage() {
            await getData(authObj); // this function runs
           // nothing below this line is run
            const createNewPage = 'url-to-get'
            driver.get(createNewPage);
        }

I know something is wrong with my getData() function, and I assume it's something to do with how I'm both returning a promise and also using resolve.



Solution 1:[1]

Just needed to remove the return Promise.resolve(promises);

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 hw-dan