I'm currently working with React JS and Google Spreadsheets and am following something similar to this article. However, I'm running into a problem. Whenever I try to connect to my spreadsheet, my React app runs successfully for a few seconds and then crashes, with this error message:
Currently, this is my code:
import {
GoogleSpreadsheet
} from 'google-spreadsheet';
function App() {
const setup = async () => {
const doc = new GoogleSpreadsheet('my spreadsheet-id'); // Obviously putting in my real spreadsheet id and data instead of this in my real code
await doc.useServiceAccountAuth({
client_email: 'my client-email',
private_key: 'my private-key'
});
await doc.loadInfo(); // loads document properties and worksheets
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
console.log(sheet.title);
console.log(sheet.rowCount);
}
My app function does have a render method and I do eventually run the setup function to connect to my spreadsheet.
Does anyone know why this is happening and how I can fix it? Thanks!