Error deploying to vercel but no errors when I run npm run build

I’m trying to deploy my project to Vercel, so before I push my changes to GitHub I run npm run build, and it builds fine with no errors but when Vercel tries to build I get an error that it can not read properties of undefined (I believe this is because the function that makes the API call did not execute). How can I fix this?

Code that I think is causing the issue

export const getStaticProps = async () => {
    const popularCountries = ["Netherlands", "Poland", "Canada"]
    let countryData = [];
    const date = getDate();
    const promise1 = popularCountries.map(async country => {
        const options = {
            method: 'GET',
            url: 'https://covid-19-statistics.p.rapidapi.com/reports',
            params: {
              region_name: country,
              date: date
            },
            headers: {
              'x-rapidapi-host': 'covid-19-statistics.p.rapidapi.com',
              'x-rapidapi-key': process.env.RAPID_API_KEY
            }
        };
        await axios.request(options).then(response => {
            const data = response.data.data;
            const country_name = data[0].region.name;
            const date = data[0].date;
            const iso = data[0].region.iso;
            let cases = 0;
            let deaths = 0;
            data.map(item => {
                cases += item.confirmed;
                deaths += item.deaths;
            })
            countryData.push({
                "country_name": country_name,
                "date": date,
                "cases": cases,
                "deaths": deaths,
                "iso": iso
            })
        })
        .catch((error) => {
            console.error("error - ", error);
        });
        return countryData;
    })
    const returnedData = await Promise.all(promise1);
    const data = returnedData[0];

    return {
        props: { data },
        revalidate: 43200
    }
}

I’m stuck because I don’t get errors on my end so I’m not sure how to debug/fix this.