Skip to content

Instantly share code, notes, and snippets.

@ljayz
ljayz / reduce.js
Created October 10, 2018 06:17
Javascript Array to Object
//from [{key1:val1},{key2:val2},{key3:val3}] to {key1:val1,key2:val2,key3:val3}
const array = [{key1:'val1'},{key2:'val2'},{key3:'val3'}];
const arrayToObject = (accumulator, currentValue) => Object.assign(accumulator, currentValue);
array.reduce(arrayToObject, {});
@ljayz
ljayz / readme.md
Last active November 16, 2018 17:25
git
@ljayz
ljayz / README.MD
Created March 12, 2019 03:16 — forked from dan1wang/README.MD
Executing App Script functions in Firebase Cloud Functions

If you are using Firebase on a Spark (free) plan, you can only make outbound networking requests to Google services. Unfortunately, that does not include Web app deployed from App Script (script.google.com/macros/s/.../exec). (Stackoverflow #43330192)

This is a crude example showing how to execute Apps Script using the scripts.run method of Apps Script API.

In this example, the Firebase app does not store the user's OAuth id token, does not validate the access token (e.g. the access token is issued for your project, not someone else's), and does not store the refresh token (access token will expire 60min after issue if not refreshed). For production, these issues must be resolved.