Load download links from live API

This commit is contained in:
Holden
2026-06-27 00:38:53 -05:00
parent e208f1ad5a
commit b1090d2dc9
7 changed files with 253 additions and 118 deletions

View File

@@ -9,44 +9,54 @@ export const api = {
builds: {
v1: {
async getLatestVersions(): Promise<ApiResult<LatestBuildsResponse>> {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/latest`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
if (!response.ok) {
console.error("Failed to load latest versions.", {
status: response.status,
statusText: response.statusText,
try {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/latest`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
return ApiResult.failure<LatestBuildsResponse>("Failed to load latest versions.");
if (!response.ok) {
console.error("Failed to load latest versions.", {
status: response.status,
statusText: response.statusText,
});
return ApiResult.failure<LatestBuildsResponse>("Failed to load latest versions.");
}
var obj = (await response.json()) as LatestBuildsResponse;
return ApiResult.success(obj);
} catch (error: unknown) {
if (error instanceof Error)
return ApiResult.failure<LatestBuildsResponse>(error.message);
return ApiResult.failure<LatestBuildsResponse>("An unexpected error occured.");
}
var obj = (await response.json()) as LatestBuildsResponse;
return ApiResult.success(obj);
},
async getPatchNotes(): Promise<ApiResult<PatchNote[]>> {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/patchNotes`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
if (!response.ok) {
console.error("Failed to load account.", {
status: response.status,
statusText: response.statusText,
async getPatchNotes(): Promise<PatchNote[]> {
try {
const response = await fetch(`${TWY_API_URL}/${BUILDS_V1}/patchNotes`, {
headers: {
"Content-Type": "application/json",
},
cache: "no-store",
});
return ApiResult.failure<PatchNote[]>("Failed to load latest versions.");
if (!response.ok) {
console.error("Failed to load account.", {
status: response.status,
statusText: response.statusText,
});
return [];
}
return (await response.json()) as PatchNote[];
} catch (error) {
return [];
}
var obj = (await response.json()) as PatchNote[];
return ApiResult.success(obj);
}
}
}