From 3b2bf0dc358c4dc20737046918a06f9cfc570b5b Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Tue, 26 Sep 2023 00:57:54 +0200 Subject: [PATCH] test: try using if statement --- packages/megalodon/src/misskey.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts index fe9f553ad4..294ad7b5ea 100644 --- a/packages/megalodon/src/misskey.ts +++ b/packages/megalodon/src/misskey.ts @@ -628,16 +628,19 @@ export default class Misskey implements MegalodonInterface { } } return this.client.post>('/api/users/search', params).then(res => { + if ((res.data as any)["error"]) { + return Object.assign(res, { + data: { + accounts: [], + statuses: [], + hashtags: [], + } + }) + } return Object.assign(res, { data: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl)) }) - }).catch(() => ({ - data: { - accounts: [], - statuses: [], - hashtags: [], - } - })) + }) } // ======================================