Giter Site home page Giter Site logo

Comments (5)

stukennedy avatar stukennedy commented on July 29, 2024

So after much trial and error, it seems that the getSheetContents function although it logs out the data correctly, somehow doesn't evaluate the data when returning from the method.
To make it work, I had to map through the rows and cells of the data.
So this method works:

const getSheetContents = () => {
  const data = getActiveDocument()
    .getActiveSheet()
    .getDataRange()
    .getValues();
  return (data || []).map(row => row.map(cell => `${cell}`));
};

Seems odd to have to do this. Have I missed something here?

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

It is strange but I know that there are restrictions on the types allowed in a server response. Does it work if you stringify data before returning it?

from react-google-apps-script.

stukennedy avatar stukennedy commented on July 29, 2024

yes doing JSON.parse(JSON.stringify(data)) does the trick.
Strange one ... I'll close this, seeing as it's nothing to do with your library.

Excellent job BTW:
I've used it to build a free tool for Remote musicians who are out of work with COVID-19
A Google Form inputting to a Google Sheet, and then a React app as a search page on the spreadsheet.
This is an excellent approach ... I'd usually use Google Firebase or AWS, but being able to make forms and sheets so quickly makes this a great option for simple webapps.

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

Great, glad it's fixed. That is weird. Anyway, adding this link to the scripts docs that talks about allowed types, in case it helps other people reading this:

https://developers.google.com/apps-script/guides/html/reference/run#parameters

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

And happy to hear this is helpful to you and others right now!

from react-google-apps-script.

Related Issues (20)

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.