1

I would like to fetch data from the google sheet with React.

I tried to use the following libraries https://github.com/ruucm/react-google-sheets https://github.com/gglukmann/use-google-sheets

However, it always requires setting the file permission to "Anyone with this link can view". We don't want to share the file outside our org. If we do this, the client cannot read the data from google sheet.

Is there any way that I can fetch data from a restricted google sheet? Thank you

coinhndp
  • 2,281
  • 9
  • 33
  • 64

1 Answers1

0

You need to use the Google Sheets API to connect to the Sheet and fetch the data.

The application would need to be authorised to run as the person who owns or is an editor of the sheet. Check out the node.js quickstart for setting up an application in the cloud console. The method you need to get data is spreadsheets.values.get.

Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54
  • So I cannot fetch the data directly from the client and would need the Node server? Any library that you recommend me to use. I would like the data as JSON –  coinhndp Feb 07 '22 at 15:25
  • You can do it from the client using the JavaScript library instead. Check out the QuickStart guide [here](https://developers.google.com/sheets/api/quickstart/js) – Rafa Guillermo Feb 07 '22 at 16:08