From 171ba6f4f579d7bec3b662e1b19651056a50f62b Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Tue, 31 Oct 2023 11:38:23 +0100 Subject: [PATCH] chore: change style of getStatusTrends --- .../src/server/api/mastodon/endpoints/search.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/search.ts b/packages/backend/src/server/api/mastodon/endpoints/search.ts index 633a3d05e4..2087d13ad0 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/search.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/search.ts @@ -47,8 +47,7 @@ export class ApiSearchMastodon { public async getStatusTrends() { try { - let map; - await fetch(`${this.BASE_URL}/api/notes/featured`, + const data = await fetch(`${this.BASE_URL}/api/notes/featured`, { method: 'POST', headers: { @@ -58,10 +57,8 @@ export class ApiSearchMastodon { body: JSON.stringify({}), }) .then(res => res.json()) - .then((data) => { - map = data.map((status: any) => this.mastoConverter.convertStatus(status)); - }); - return map; + .then(data => data.map((status: any) => this.mastoConverter.convertStatus(status))); + return data; } catch (e: any) { console.error(e); return []; @@ -82,7 +79,7 @@ export class ApiSearchMastodon { return Promise.all(data.map(async (suggestion: any) => { suggestion.account = await this.mastoConverter.convertAccount(suggestion.account); return suggestion; })); } catch (e: any) { console.error(e); - return e.response.data; + return []; } } }