Skip to content

Commit 60603d2

Browse files
committed
Use alert() for the WASM example crate
1 parent 387c21f commit 60603d2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

wasm/example/src/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from browser import fetch
1+
from browser import fetch, alert
22

33
def fetch_handler(repos):
44
star_sum = 0
55
for repo in repos:
66
star_sum += repo['stars']
7-
print(f'Average github trending star count: {star_sum / len(repos)}')
8-
7+
alert(f'Average github trending star count: {star_sum / len(repos)}')
98

109
fetch(
1110
'https://github-trending-api.now.sh/repositories',
1211
response_format='json',
13-
).then(fetch_handler)
12+
).then(fetch_handler, lambda err: alert(f"Error: {err}"))

0 commit comments

Comments
 (0)