Coder Social home page Coder Social logo

gglukmann / use-google-sheets Goto Github PK

View Code? Open in Web Editor NEW
94.0 94.0 13.0 1.88 MB

๐Ÿ“ A React Hook for getting data from Google Sheets API v4

License: MIT License

HTML 7.73% TypeScript 87.67% JavaScript 4.60%
google-sheets google-sheets-api google-sheets-api-v4 hooks react react-hooks

use-google-sheets's Issues

Links in field values

Hello. I've been using this hook for an app I'm building that uses a Google Sheet as the data source. It's been great to use and super easy to set up (specially compared to a lot of the other options out there) but I've got an issue where a column I need to view has a link in the data.

Screenshot 2023-03-17 at 08 57 18

This is just returning as a flat string value like "TRK-FORD-13-433" rather than the actual contents of the cell I was expecting.

If I'm just not doing something correctly then please let me know, otherwise is there a way around this?

Thanks

api key and sheet id exposed in network request

Hi,

Thanks for this nice library! very easy to use!
I found out although I put my api key and sheet id in .env file, after I deploy my app, user can see the requested url in the network tab in browser console, which contains the api key and sheet id...
I am not sure though, do you think we can use post request or some other way to secret the url?

Thanks again!

Don't discard row zero!

Row zero may contain the table head, or it may contain data. Please dont discard it. Now I will have to use map-reduce to get the table head out of it. (or make a PR)

Feature Request: Get URL of "image in cell"

Hi, thanks a lot for this great project. I have a question / feature request.

Currently when i have an image in a cell in a sheet, the hook returns an empty string.

image

activityDescription: "Taking the bike to the barber"
activityImage: ""
experienceValue: "0"
needs: ""
stage: "Before"

Is it possible to retrieve the URL to that image? I think this would be a very useful feature.

The caller does not have permission

Hi. I'm receiving the error "The caller does not have permission" when running this.

I've configured the app in Google Console to allow the Google Sheets APIโ€”creating an API Key and a Service Account. The API Key is used in the app as GATSBY_GOOGLE_SHEETS_API_KEY, GATSBY_GOOGLE_SHEETS_SHEET_ID added from the Sheet URL, and the Service Account email was added to the Google Sheet with full Editor permissions.

I'm not entirely sure which apiKey value to set in the application env variable. Where is the correct API Key found/created? Is it created in the Service Account, the general Credentials settings in Console, or one of the values in the json file credentials?

Application Code (typescript)

const { data, loading, error } = useGoogleSheets({
    apiKey: process.env.GATSBY_GOOGLE_SHEETS_API_KEY as string,
    sheetId: process.env.GATSBY_GOOGLE_SHEETS_SHEET_ID as string,
  });

Console error:

{
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
}

Is the data memoized?

Im rewriting my display of the data now (a table) - react-table wants a memoized data set. Is the data memoized? I'm sorry I'm kind of a noob. If not memoized how do i memoize it?

const {
    data: sheetData,
    loading,
    error,
  } = useMemo(() => {
    return useGoogleSheets({
      apiKey: GAPI_CONFIG.apiKey,
      sheetId,
    });
  }, [sheetId]);

React Hook "useGoogleSheets" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.

Feature Request: Add a new prop that lets us set the row number of the row we want to use for the header

Basically I need a way to pull in the data of a spreadsheet that does not use the first row as its header.
For example with...
https://docs.google.com/spreadsheets/d/1nh82R5ROEV1idhYQeujsBNM9mNEatkISdbqQYvR6ZZI/edit?usp=sharing

I want to be able to do something like...

useGoogleSheets({
    apiKey: APIKEY,
    sheetId: GOOGLESHEETID,
    headerRow: 7,
  });

To tell it to use the 7th row as the header instead of the first and ignore everything above it.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.