Created
July 11, 2020 05:34
-
-
Save drewrothstein/e7e9109e42679b810bdeac9db699983c to your computer and use it in GitHub Desktop.
Mixing Async/Await & Promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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