Created
July 10, 2017 02:52
-
-
Save kdepp/de1723409c1a94b8dde0941c8467e3cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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