3637async function generateGraph(username) {
38console.log(`Fetching contributions for ${username}`);
39try {
40const contributionData = await fetchContributions(username);
41const totalContributions = Object.values(contributionData).reduce((sum, count) => sum + count, 0);
42console.log(`Total contributions: ${totalContributions}`);
56}
5758async function fetchContributions(username) {
59const contributionMap = {};
60const valsUrl = `https://api.val.town/v1/alias/${username}/vals`;
61const valsResponse = await fetch(valsUrl);
62if (!valsResponse.ok) {
63throw new Error(`HTTP error! status: ${valsResponse.status}`);
83contributionMap[creationDate] = (contributionMap[creationDate] || 0) + 1;
8485await fetchValVersions(val.id, contributionMap, creationDate);
86}
87}
90}
9192async function fetchValVersions(valId, contributionMap, creationDate) {
93const versionsUrl = `https://api.val.town/v1/vals/${valId}/versions`;
94try {
95const versionsResponse = await fetch(versionsUrl);
96if (!versionsResponse.ok) {
97throw new Error(`HTTP ${versionsResponse.status}`);
115}
116} catch (error) {
117console.error(`Failed to fetch versions for val ${valId}:`, error.message);
118}
119}
199}
200201export default app.fetch;
3031async function loadPage(url) {
32const response = await fetch(url)
33const body = await response.text()
34const $ = cheerio.load(body)
extremePlumCariboumain.tsx15 matches
21setUsername(usernameFromPath || 'ejfox'); // Default to 'ejfox' if no username provided
22
23const fetchVals = async () => {
24setLoading(true);
25setVals([]);
27setDebugInfo([]);
28try {
29setDebugInfo(prev => [...prev, `Fetching vals for ${usernameFromPath || 'ejfox'}...`]);
30const response = await fetch(`/vals/${usernameFromPath || 'ejfox'}`);
31if (!response.ok) {
32throw new Error(`HTTP error! status: ${response.status}`);
40}
41
42setDebugInfo(prev => [...prev, `Fetched ${data.vals.length} vals`]);
43
44// Fetch emojis for each val with a delay
45for (const val of data.vals) {
46setDebugInfo(prev => [...prev, `Fetching emoji for ${val.name}...`]);
47const emoji = await fetchEmojiForName(val.name);
48setVals(prevVals => [...prevVals, { ...val, emoji }]);
49await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay
50}
51
52setDebugInfo(prev => [...prev, 'All vals and emojis fetched']);
53} catch (error) {
54console.error('Error fetching vals:', error);
55setError(error.toString());
56setDebugInfo(prev => [...prev, `Error: ${error.message}`]);
60};
6162fetchVals();
63}, []);
64119}
120121async function fetchEmojiForName(name) {
122try {
123const response = await fetch(`/emoji/${encodeURIComponent(name)}`);
124if (response.ok) {
125const data = await response.json();
126return data.emoji;
127}
128console.error('Error fetching emoji:', response.statusText);
129} catch (error) {
130console.error('Error fetching emoji:', error);
131}
132return '❓'; // Placeholder
172for await (const val of client.users.vals.list(user.id, { limit: 100 })) {
173vals.push(val);
174await new Promise(resolve => setTimeout(resolve, 2000)); // 2 second delay between fetches
175}
176
allvalsindexmain.tsx2 matches
1920useEffect(() => {
21fetch('/vals')
22.then(response => {
23if (!response.ok) {
39})
40.catch(error => {
41console.error('Error fetching vals:', error);
42setError(error.toString());
43setLoading(false);
sqliteExplorerAppmain.tsx4 matches
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
blob_adminmain.tsx2 matches
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138139export default modifyFetchHandler(passwordAuth(app.fetch));
11const imageUrl = "https://charlypoly-httpapiscreenshotpageexample.web.val.run/?url=" + url.origin
12// return Response.redirect(imageUrl, 302)
13const res = await fetch(imageUrl)
14const blob = await res.blob()
15return new Response(blob, { headers: { "Content-Type": "image/png" } })
calculateTransitAPImain.tsx4 matches
82const distanceMatrixUrl = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${encodeURIComponent(origin)}&destinations=${encodeURIComponent(destinations)}&mode=driving&key=${apiKey}`;
83
84const response = await fetch(distanceMatrixUrl);
85const data = await response.json();
86117}
118119const directionsResponse = await fetch(directionsUrl);
120const directionsData = await directionsResponse.json();
121132const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
133134const directionsResponse = await fetch(directionsUrl);
135const directionsData = await directionsResponse.json();
136146async function getZipCode(address: string, apiKey: string): Promise<string> {
147const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(address)}&key=${apiKey}`;
148const response = await fetch(geocodeUrl);
149const data = await response.json();
150
fluxImageGeneratormain.tsx1 match
81setError("");
82try {
83const response = await fetch("/generate", {
84method: "POST",
85headers: { "Content-Type": "application/json" },
weatherGPTmain.tsx1 match
4let location = "Wolfsburg";
5let lang = "de";
6const weather = await fetch(
7`https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());