mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-21 18:47:26 -07:00
Gracefully fall-back to the tag handle for accounts that do not pass the first lookup
This commit is contained in:
parent
ea3e389d01
commit
6d80fa565b
1 changed files with 13 additions and 1 deletions
|
@ -12,6 +12,13 @@ async function apiRequest(url, options = null)
|
|||
}
|
||||
|
||||
return await fetch(url, options ?? {})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response;
|
||||
}
|
||||
|
||||
throw new Error(`Error fetching ${url}: ${response.status} ${response.statusText}`);
|
||||
})
|
||||
.then(response => response.json())
|
||||
.catch(error => {
|
||||
console.error(`Error fetching ${url}: ${error}`);
|
||||
|
@ -267,7 +274,12 @@ class MastodonApiClient extends ApiClient {
|
|||
|
||||
async getUserIdFromHandle(handle) {
|
||||
const url = `https://${this._instance}/api/v1/accounts/lookup?acct=${handle.baseHandle}`;
|
||||
const response = await apiRequest(url, null);
|
||||
let response = await apiRequest(url, null);
|
||||
|
||||
if (!response) {
|
||||
const url = `https://${this._instance}/api/v1/accounts/lookup?acct=${handle}`;
|
||||
response = await apiRequest(url, null);
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue