mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-23 03:17:47 +01:00
this is one of the commits ever lol
This commit is contained in:
parent
44f05a83af
commit
3f2576c83c
1 changed files with 15 additions and 10 deletions
|
@ -46,14 +46,19 @@ async _getEngagementData() {
|
||||||
|
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
|
|
||||||
|
try {
|
||||||
var engagementP = await fetch(apiUrl).then((res) => res.json());
|
var engagementP = await fetch(apiUrl).then((res) => res.json());
|
||||||
|
|
||||||
if(!engagementP.dislikes) {
|
if (typeof engagementP.dislikes === 'number') {
|
||||||
|
return engagementP;
|
||||||
|
} else {
|
||||||
|
throw new Error("API response doesn't contain valid dislikes count. Using fallback URL.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
var engagement = await fetch(fallbackUrl).then((res) => res.json());
|
var engagement = await fetch(fallbackUrl).then((res) => res.json());
|
||||||
return engagement;
|
return engagement;
|
||||||
} else {
|
|
||||||
return engagementP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue