diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-09-26 00:57:54 +0200 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-09-26 00:57:54 +0200 |
| commit | 3b2bf0dc358c4dc20737046918a06f9cfc570b5b (patch) | |
| tree | 338ed4f000009e4321127d25ff3ff2e69c361035 /packages/megalodon/src | |
| parent | test: attempt catching error (diff) | |
| download | sharkey-3b2bf0dc358c4dc20737046918a06f9cfc570b5b.tar.gz sharkey-3b2bf0dc358c4dc20737046918a06f9cfc570b5b.tar.bz2 sharkey-3b2bf0dc358c4dc20737046918a06f9cfc570b5b.zip | |
test: try using if statement
Diffstat (limited to 'packages/megalodon/src')
| -rw-r--r-- | packages/megalodon/src/misskey.ts | 17 |
1 files 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<Array<MisskeyAPI.Entity.UserDetail>>('/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: [], - } - })) + }) } // ====================================== |