1

I am trying to use papaparse inside my Next.js page. I am using react-papaparse package which is a React wrapper for Papaparse. I am trying to parse remote CSV file inside getStaticProps() function but the error I get is XMLHttpRequest is not defined.

I know that getStaticProps() is executed on Node.js but I don't know how to use react-paparse correctly to avoid XMLHttpRequest call. Here is my code:

// index.js Next.js page

import { usePapaParse } from "react-papaparse";

export async function getStaticProps(context) {
  const { readRemoteFile } = usePapaParse();
  readRemoteFile(googleSheetUrl, {
    complete: (results) => {
      console.log("PAPAPARSE::complete", results)
    },
  });
}
Primoz Rome
  • 10,379
  • 17
  • 76
  • 108

0 Answers0