mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-22 02:57:25 -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 ?? {})
|
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())
|
.then(response => response.json())
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(`Error fetching ${url}: ${error}`);
|
console.error(`Error fetching ${url}: ${error}`);
|
||||||
|
@ -267,7 +274,12 @@ class MastodonApiClient extends ApiClient {
|
||||||
|
|
||||||
async getUserIdFromHandle(handle) {
|
async getUserIdFromHandle(handle) {
|
||||||
const url = `https://${this._instance}/api/v1/accounts/lookup?acct=${handle.baseHandle}`;
|
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) {
|
if (!response) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue