Skip to content

Commit

Permalink
adds missing await
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed May 18, 2024
1 parent 2a584d4 commit a18d3f1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions activities-bot/src/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ function isAllowedEvent(event) {
}
}

const throwForHttpError = async (res) => {
const throwForHttpError = async (promise) => {
const res = await promise;

if (!res.ok) {
throw new Error(await res.text());
}
Expand Down Expand Up @@ -120,8 +122,8 @@ const leaderboardApiHeaders = {
const eodUpdatesApi = `${LEADERBOARD_URL}/api/slack-eod-bot/eod-updates`;

export async function getEODUpdates() {
const res = throwForHttpError(
await fetch(eodUpdatesApi, {
const res = await throwForHttpError(
fetch(eodUpdatesApi, {
headers: leaderboardApiHeaders,
}),
);
Expand All @@ -130,8 +132,8 @@ export async function getEODUpdates() {
}

export async function flushEODUpdates() {
const res = throwForHttpError(
await fetch(eodUpdatesApi, {
const res = await throwForHttpError(
fetch(eodUpdatesApi, {
headers: leaderboardApiHeaders,
method: "DELETE",
}),
Expand All @@ -144,8 +146,8 @@ const slackApiHeaders = {
};

export async function sendSlackMessage(channel, text, blocks) {
const res = throwForHttpError(
await fetch("https://slack.com/api/chat.postMessage", {
const res = await throwForHttpError(
fetch("https://slack.com/api/chat.postMessage", {
method: "POST",
headers: slackApiHeaders,
body: JSON.stringify({
Expand Down

0 comments on commit a18d3f1

Please sign in to comment.