Skip to content

Instantly share code, notes, and snippets.

@kdepp
Created July 10, 2017 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdepp/de1723409c1a94b8dde0941c8467e3cd to your computer and use it in GitHub Desktop.
Save kdepp/de1723409c1a94b8dde0941c8467e3cd to your computer and use it in GitHub Desktop.
// Old
const result = await rp(options)
if (!result.ok) {
console.error("The request was not ok: " + JSON.stringify(result));
return response.header("Location", `https://us-central1-teamsync-working-v2.firebaseapp.com`).send(302);
}
await admin.database().ref("installations").child(result.team_id).set({
token: result.access_token,
team: result.team_id,
webhook: {
url: result.incoming_webhook.url,
channel: result.incoming_webhook.channel_id
}
});
response.header("Location", `https://us-central1-teamsync-working-v2.firebaseapp.com/success.html`).send(302);
// New
rp(options)
.then(function (result) {
if (!result.ok) {
console.error("The request was not ok: " + JSON.stringify(result));
return response.header("Location", `https://us-central1-teamsync-working-v2.firebaseapp.com`).send(302);
}
return admin.database().ref("installations").child(result.team_id).set({
token: result.access_token,
team: result.team_id,
webhook: {
url: result.incoming_webhook.url,
channel: result.incoming_webhook.channel_id
}
})
.then(function () {
response.header("Location", `https://us-central1-teamsync-working-v2.firebaseapp.com/success.html`).send(302);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment