@webcontext/google v0.1.55
User Manual for Google Cloud API Helper Functions for Webcontext Users
Prerequisites
- Environment Variables: Add the following environment variables to a .env file in the project root. Ensure the 'dotenv' package is installed to load these variables:
GOOGLE_CLOUD_PROJECT_ID
GOOGLE_CLOUD_CLIENT_EMAIL
GOOGLE_CLOUD_PRIVATE_KEY
- Google Cloud Setup: Ensure that the Google Cloud API client email is added as an editor to any Google Sheet that the helper functions will modify.
Available APIs
Sheets API
: Provides helper functions for managing Google Sheets data.
Available helper functions for sheets
- Function:
updateSheets
Description: This function updates data in a Google Spreadsheet, specified by a unique
spreadsheetId
, with given headers and rows of data.Arguments:
obj
: An object containingheaders
andvalues
.headers
: An array of strings representing the column headers for the sheet. Example:['Category', 'Item', 'Quantity']
.values
: A 2D array where each inner array represents a row of data, aligning with the headers. Example:[['Electronics', 'Laptop', '15'], ['Appliances', 'Toaster', '5']]
.
spreadsheetId
: A string representing the unique identifier of the Google Spreadsheet (found in the Google Sheets URL after/d/
and before/edit
).
Note: The Google Cloud API client e mail must have editor permissions on the target spreadsheet.
Example usage
import sheets from './services/sheets.js';
const data = {
headers: ['Category', 'Item', 'Quantity'],
values: [
['Electronics', 'Laptop', '15'],
['Appliances', 'Toaster', '5'],
],
};
const spreadsheetId = 'your_spreadsheet_id_here';
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago