We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 35533f3 commit 5a0e47eCopy full SHA for 5a0e47e
apps/landing/src/app/StarButton.tsx
@@ -13,16 +13,17 @@ export default function StarButton() {
13
const abortController = new AbortController()
14
const fetchStarCount = async () => {
15
try {
16
- const res = await fetch(
+ const data = await fetch(
17
'https://api.github.com/repos/dev-five-git/devup-ui',
18
{
19
signal: abortController.signal,
20
},
21
- )
22
- const data = await res.json()
+ ).then((res) => res.json())
23
setStarCount(data.stargazers_count)
24
} catch (error) {
25
console.error(error)
+ } finally {
26
+ setStarCount((prev) => (typeof prev === 'number' ? prev : -1))
27
}
28
29
fetchStarCount()
0 commit comments