2.0.1 • Published 6 years ago

google-document-loader v2.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

google-document-loader

A node module for simple download a google drive document.

Changes in 2.0

Since 2.0 promises are used instead of callbacks.

Usage

This sample uses parcel as bundler. Install parcel with

npm install -g parcel-bundler

Create a new project.

mkdir showdrivedocument
cd showdrivedocument
npm init -y
npm install --save google-document-loader
npm install --save-dev babel-plugin-add-module-exports
npm install --save-dev babel-preset-es2015

Next go to the Google Developer Console (Google Developer Console) and create a new project, a OAuth Client Id and activate the Drive API (see Google Drive REST API Quickstart).

Now create an index.js file. Replace <INSERT_CLIENT_ID> with your created Google Client Id. Replace <INSERT_DOCUMENT_ID> with the Id from the Google Drive document that will be downloaded.

import GoogleLoadDocument from 'google-document-loader';

let options = {
  "clientId": "<INSERT_CLIENT_ID>",
  "scope": [
    "profile",
    "https://www.googleapis.com/auth/drive"
  ]
};

let loadDocument = new GoogleLoadDocument(options);
document.getElementById('loadButton').onclick=function() {
  loadDocument.getDocument('<INSERT_DOCUMENT_ID>').then((body) => {
    document.getElementById('viewer').innerHTML=body;
  },
  (reason) => {
    alert('Error:' + reason);
  });
};

and a index.html

<html>
<body>
  <button id="loadButton">Load</button>
  <div id="viewer" />
  <script src="index.js"></script>
</body>
</html>

Now start the app with

parcel index.html

and open your browser and go to http://localhost:1234

2.0.1

6 years ago

2.0.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago