Skip to content

Instantly share code, notes, and snippets.

@jthegedus
Created November 29, 2017 13:23
Show Gist options
  • Save jthegedus/659afa14e70034b593feac80a50f320f to your computer and use it in GitHub Desktop.
Save jthegedus/659afa14e70034b593feac80a50f320f to your computer and use it in GitHub Desktop.
ES6+ in Cloud Functions for Firebase - input for the last 3 examples
// input - async/awaiy with CommonJS module syntax
const functions = require('firebase-functions');
// returns a string after 5 seconds
const message = () => {
return new Promise(resolve => {
setTimeout(() => {
resolve(`from Babelified Cloud Functions!`)
}, 5000)
})
}
module.exports.helloWorld = functions.https.onRequest(async (req, res) => {
let world = await message();
res.status(200).send(`Hello ${world}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment