test: try using if statement

This commit is contained in:
Mar0xy 2023-09-26 00:57:54 +02:00
parent 77754cc3d8
commit 3b2bf0dc35
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
1 changed files with 10 additions and 7 deletions

View File

@ -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: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl))
})
}).catch(() => ({
data: {
accounts: [],
statuses: [],
hashtags: [],
}
}))
})
}
return Object.assign(res, {
data: res.data.map(u => MisskeyAPI.Converter.userDetail(u, this.baseUrl))
})
})
}
// ======================================