9
10 useEffect(() => {
11 fetchVoiceNotes();
12 }, []);
13
14 const fetchVoiceNotes = async () => {
15 try {
16 setLoading(true);
17 const response = await fetch('/api/voicenotes');
18 const data = await response.json();
19
21 setVoiceNotes(data.voiceNotes || []);
22 } else {
23 setError(data.error || 'Failed to fetch voice notes');
24 }
25 } catch (err) {
26 setError('Failed to load voice notes');
27 console.error('Error fetching voice notes:', err);
28 } finally {
29 setLoading(false);
120
121 try {
122 const response = await fetch(`/api/voicenotes/${voiceNoteId}`, {
123 method: 'DELETE'
124 });
160 <p className="text-red-600 mb-4">{error}</p>
161 <button
162 onClick={fetchVoiceNotes}
163 className="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700"
164 >
177 </h2>
178 <button
179 onClick={fetchVoiceNotes}
180 className="px-4 py-2 bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 text-sm"
181 >
46 </div>
47 )
48 : <div className="text-2xl mt-2.5">Unable to fetch weather data</div>}
49 </Content>
50 <Footer />
1import fetchWithCache from "./fetchWithCache.ts";
2
3export type WEATHER_FORECAST = {
39
40 // Cache for 30 minutes
41 const data: WEATHER_FORECAST = await fetchWithCache(apiUrl, cacheKey, 30).then((res) => res.json());
42 return new Response(JSON.stringify(data), {
43 headers: {
1import fetchWithCache from "./fetchWithCache.ts";
2
3const GUARDIAN_API_KEY = Deno.env.get("GUARDIAN_API_KEY");
25 const cacheKey = `guardian_headlines_${size}`;
26
27 const data = await fetchWithCache(apiUrl, cacheKey).then((res) => res.json());
28 return new Response(JSON.stringify(data), {
29 headers: {
47 <h3 class="text-xl pb-2">Example frame previews</h3>
48 <p>
49 Frames data is fetched, cached, and displayed with val.town, then fetched and rendered on an e-ink
50 display.
51 </p>
33 ))
34 )
35 : <div className="text-2xl mt-2.5">Unable to fetch data</div>}
36 </ul>
37
1import fetchWithCache from "./fetchWithCache.ts";
2
3export type HEMOLOG_TREATMENT = {
22 const cacheKey = "hemolog-recent-treatments";
23
24 const data: HEMOLOG_TREATMENT[] = await fetchWithCache(apiUrl, cacheKey).then((res) => res.json());
25 return new Response(JSON.stringify(data), {
26 headers: {
141 )
142 : (
143 "Unable to fetch GitHub data"
144 )}
145 </div>
44 }
45 } catch (e) {
46 // Cache miss, continue to fetch new data
47 }
48
88 const apiUrl = "https://api.github.com/graphql";
89
90 const response = await fetch(apiUrl, {
91 method: "POST",
92 headers: {
148 });
149 } catch (error) {
150 console.error("Error fetching GitHub data:", error);
151 const errorResult: GitHubContributionsResponse = {
152 contributions: [],
153 totalContributions: 0,
154 username: queryUsername,
155 error: error.message || "Failed to fetch GitHub data",
156 };
157
16
17 try {
18 const response = await fetch(generateUrl);
19 if (!response.ok) {
20 throw new Error(`APIFlash responded with status: ${response.status}`);