Use ApexCharts.exec(id, ‘dataURI’) to get a URI and input that to react pdf

all.

I am trying to get my data using this function:

function getDataUri() {
  ApexCharts.exec('chartID', 'dataURI').then(({ imgURI }) => {
    console.log(imgURI);
  });
}

However, when I put that into my export default function ie

export default function Page() {
  console.log(getDataUri());

  return (
      <div>
        <Chart />
      <div>
    );
  }

The chart renders on the page when I do not input console.log(getDataUri());. When I do, I get the following error: Uncaught TypeError: apexcharts__WEBPACK_IMPORTED_MODULE_4__.ApexCharts is undefined

I have run npm install apexcharts, and I import it as import ApexCharts from ‘apexcharts’.

Please advise how to fix this so I can access the uri and then input it as an img to my pdf!