Skip to content

Commit ae32bdd

Browse files
committed
refactor(www): rename fetchChangelog to getChangelog and enhance error handling
1 parent 6928acb commit ae32bdd

File tree

1 file changed

+6
-4
lines changed
  • www/src/features/about-modal/changelog

1 file changed

+6
-4
lines changed

Diff for: www/src/features/about-modal/changelog/atoms.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function isChangelogResponse(data: unknown): data is ChangelogResponse {
1212
return typeof data === "object" && data !== null && "body" in data;
1313
}
1414

15-
async function fetchChangelog() {
15+
async function getChangelog() {
1616
return fetch(
17-
`/api/repos/${release.owner}/${release.repo}/releases/latest`,
17+
`https://api.github.com/repos/${release.owner}/${release.repo}/releases/latest`,
1818
{
1919
headers: {
2020
Accept: "application/vnd.github.v3+json",
@@ -23,7 +23,9 @@ async function fetchChangelog() {
2323
)
2424
.then((response) => {
2525
if (!response.ok) {
26-
throw new Error("Network response was not ok");
26+
throw new Error("Network response was not ok", {
27+
cause: response.status,
28+
});
2729
}
2830
return response.json();
2931
})
@@ -41,7 +43,7 @@ async function fetchChangelog() {
4143
);
4244
}
4345

44-
const changelogAtom: Atom<Promise<string>> = atomWithCache(fetchChangelog, {
46+
const changelogAtom: Atom<Promise<string>> = atomWithCache(getChangelog, {
4547
shouldRemove(createdAt) {
4648
return Date.now() - createdAt > CACHE_TTL_S * 1000;
4749
},

0 commit comments

Comments
 (0)