From d5cc3cd9700fd37b386e73835e4d80edb51fc73d Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 10 Jun 2023 20:40:52 -0400 Subject: [PATCH] refactor: directly return promises instead of awaiting --- legacy/src/services/slack.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/legacy/src/services/slack.ts b/legacy/src/services/slack.ts index 47b13c50..9f0c22de 100644 --- a/legacy/src/services/slack.ts +++ b/legacy/src/services/slack.ts @@ -290,13 +290,14 @@ export class SlackClient { throw new Error('Error: No channel specified') } - const res = await this.api.post('chat.postMessage', { - json: { - channel: this.defaultChannel, - ...options - } - }) - return res.json() + return this.api + .post('chat.postMessage', { + json: { + channel: this.defaultChannel, + ...options + } + }) + .json() } /** @@ -305,20 +306,22 @@ export class SlackClient { public async fetchConversationHistory( options: SlackConversationHistoryParams ) { - const response = await this.api.get('conversations.history', { - searchParams: options - }) - return response.json() + return this.api + .get('conversations.history', { + searchParams: options + }) + .json() } /** * Fetches replies to a message in a channel. */ protected async fetchReplies(options: SlackConversationRepliesParams) { - const response = await this.api.get('conversations.replies', { - searchParams: options - }) - return response.json() + return this.api + .get('conversations.replies', { + searchParams: options + }) + .json() } /**