Skip to content

Instantly share code, notes, and snippets.

@drewrothstein
Created July 11, 2020 05:34
Show Gist options
  • Save drewrothstein/e7e9109e42679b810bdeac9db699983c to your computer and use it in GitHub Desktop.
Save drewrothstein/e7e9109e42679b810bdeac9db699983c to your computer and use it in GitHub Desktop.
Mixing Async/Await & Promises
var saveDoc = async function(data) {
const saveData = {
...data,
...{ savedTimestamp: admin.firestore.FieldValue.serverTimestamp() }
}
db.collection('Auth').doc(data.team_id).set(saveData).then(res => {
console.log('Auth data updated for:', data.team_id);
});
}
module.exports.install = (app, slack) => {
app.route('/oauth')
.get((request, response) => {
console.log('Request for /oauth');
const payload = request.query;
if (!payload.code) {
return response.redirect(302, installUrl);
}
return slack.oauth.v2
.access({
client_id: process.env.SLACK_CLIENT_ID,
client_secret: process.env.SLACK_CLIENT_SECRET,
code: payload.code,
state: payload.state
})
.then(data => {
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment