Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put data in my Google spreadsheet using React JS [duplicate]

I used this as reference https://github.com/ruucm/react-google-sheets but i kept getting a gapi 404 error whenever i would run this I have a hunch that the github link does not exists and therefore my app could not work

Or maybe I'm wrong.

Is there a really nice reference where I can send data from react js to google spreadsheets?

I've tried numerous attempts on spreadsheets but it does the opposite where in the spreadsheet will give data to the app What I need is REACT TO SPREADSHEET

import React, { Component } from 'react';
import ReactGoogleSheets from 'react-google-sheets';

class GoogleSheets extends Component {

    constructor(props) {
        super(props)
        this.state = {
            sheetLoaded: false,
        }
    }

    render() {
        return (

            <ReactGoogleSheets
                clientId={'243...apps.googleusercontent.com'}
                apiKey={'AIza...'}
                spreadsheetId={'2PAC...'}
                afterLoading={() => this.setState({ sheetLoaded: true })}
            >
                {this.state.sheetLoaded ?
                    <div>
                        {/* Access Data */}
                        {console.log('Your sheet data : ', this.props.getSheetsData( 'gSheets' ))}
                        {/* Update Data */}
                        <button onClick={() => {
                            this.props.updateCell(
                                'gSheets', // sheetName
                                'b', // column
                                2, // row
                                'TESTING', // value
                                null, // successCallback
                                (error) => {
                                    console.log('error', error)
                                } // errorCallback
                            );
                        }}>update cell!</button>
                    </div>
                    :
                    'loading...'
                }
            </ReactGoogleSheets>


        )

    }

}
export default GoogleSheets;

The output should be a button, with data inside it, to send it in the spreadsheet

but all I get is this error

gapi.js:257 GET https://apis.google.com//scs/apps-static//js/k=oz.gapi.ko.u0WhFdqJrXQ.O/m=auth2,client/rt=j/sv=1/d=1/ed=1/am=QQE/rs=AGLTcCO-v0Extr2gWwJAKxa0xtQS573uyA/cb=gapi.loaded_0 net::ERR_ABORTED 404

like image 654
Olufsen Avatar asked Nov 07 '22 16:11

Olufsen


1 Answers

update gapi.js or update it "by hand" in your

node_modules/react-google-sheets/google-sheet-connector/gapi.js

and add the contents from https://apis.google.com/js/api.js. Keep the last line where it says

module.exports = gapi;
like image 87
vinc4 Avatar answered Nov 10 '22 00:11

vinc4