Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=fetch&page=721&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 15782 results for "fetch"(7758ms)

stevensDemo.cursorrules5 matches

@Fewl•Updated 2 months ago
163```
164
1655. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
166```ts
167const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
168```
169
242
243 // Inject data to avoid extra round-trips
244 const initialData = await fetchInitialData();
245 const dataScript = `<script>
246 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
300
3015. **API Design:**
302 - `fetch` handler is the entry point for HTTP vals
303 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
304 - Properly handle CORS if needed for external access

stevensDemoApp.tsx17 matches

@Fewl•Updated 2 months ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

onlyRuckusDropsmain.tsx8 matches

@kamalnrf•Updated 2 months ago
5const STORAGE_KEY = "kerehaklu_snapshot";
6
7async function fetchWebpage(url: string): Promise<string> {
8 const response = await fetch(url, {
9 headers: {
10 "User-Agent":
14
15 if (!response.ok) {
16 throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
17 }
18
50}
51
52async function fetchData(): Promise<any> {
53 const response = await fetch(
54 "https://api.dm2buy.com/v3/product/store/2a6975fbe4b4b5097f969318609fab84/collectionv2?page=1&limit=20&source=web",
55 {
61 );
62 if (!response.ok) {
63 throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
64 }
65 return response.json();
83export default async function(interval: Interval) {
84 try {
85 const data = await fetchData();
86 // const currentContent = await fetchWebpage(URL);
87 const currentHash = createJSONSnapshot(data);
88 const previousHash = await getPreviousSnapshot();

test-multiembedt.tsx3 matches

@temptemp•Updated 2 months ago
9export default async function(req: Request): Promise<Response> {
10 const API_URL: string = "https://api.val.town";
11 async function proxiedFetch(input: string | URL, requestInit?: RequestInit) {
12 let query = new URLSearchParams({
13 url: input.toString(),
14 });
15 return fetch(`${API_URL}/v1/fetch?${query}`, {
16 ...requestInit,
17 // @ts-ignore
24 });
25 }
26 return new Response(await (await proxiedFetch(new URL(req.url).searchParams.get("url"))).body);
27}

untitled-5703index.ts2 matches

@angelaphiri•Updated 2 months ago
36 let html = await readFile("/frontend/index.html", import.meta.url);
37
38 // Fetch initial data
39 const jobs = await getAllJobs();
40 const messages = await getMessages(20);
118
119// Export the app
120export default app.fetch;

untitled-5703index.js15 matches

@angelaphiri•Updated 2 months ago
132
133// Jobs functionality
134async function fetchJobs() {
135 try {
136 const response = await fetch('/api/jobs');
137 if (!response.ok) throw new Error('Failed to fetch jobs');
138
139 state.jobs = await response.json();
140 renderJobs();
141 } catch (error) {
142 console.error('Error fetching jobs:', error);
143 elements.jobsList.innerHTML = '<p class="text-red-500">Error loading jobs. Please try again later.</p>';
144 }
188 elements.submitJobButton.textContent = 'Posting...';
189
190 const response = await fetch('/api/jobs', {
191 method: 'POST',
192 headers: {
234}
235
236async function fetchMessages() {
237 try {
238 const response = await fetch('/api/messages');
239 if (!response.ok) throw new Error('Failed to fetch messages');
240
241 const messages = await response.json();
249 }
250 } catch (error) {
251 console.error('Error fetching messages:', error);
252 }
253}
292 };
293
294 const response = await fetch('/api/messages', {
295 method: 'POST',
296 headers: {
305 elements.chatInput.value = '';
306
307 // Fetch latest messages
308 await fetchMessages();
309 } catch (error) {
310 console.error('Error sending message:', error);
330// Setup polling for chat messages
331function setupMessagePolling() {
332 // Initial fetch
333 fetchMessages();
334
335 // Poll every 5 seconds
336 state.messagePollingInterval = setInterval(fetchMessages, 5000);
337}
338

Mercurymercury.ts4 matches

@thirdsouth•Updated 2 months ago
44
45 try {
46 const response = await fetch(url, options);
47
48 console.log(`Response status: ${response.status}`);
72 async getAccounts(): Promise<MercuryAccount[]> {
73 try {
74 console.log('Fetching accounts from Mercury API');
75 // Try the documented endpoint structure first
76 const response = await this.request<{ accounts: MercuryAccount[] }>('/accounts');
102 async getAccount(accountId: string): Promise<MercuryAccount> {
103 try {
104 console.log(`Fetching account ${accountId}`);
105 const response = await this.request<{ account: MercuryAccount } | MercuryAccount>(`/accounts/${accountId}`);
106
127 ): Promise<MercuryPaginatedResponse<MercuryTransaction>> {
128 try {
129 console.log(`Fetching transactions for account ${accountId}, limit: ${limit}`);
130
131 // Try different endpoint formats to handle potential API variations

Mercuryindex.ts6 matches

@thirdsouth•Updated 2 months ago
38 return formatAccountBalances(accounts);
39 } catch (error) {
40 console.error('Error fetching balances:', error);
41 return formatErrorMessage('Failed to fetch account balances. Please try again later.');
42 }
43}
51
52 // Get all accounts first
53 console.log('Fetching accounts...');
54 const accounts = await mercury.getAccounts();
55 console.log('Accounts fetched:', JSON.stringify(accounts));
56
57 if (accounts.length === 0) {
69 limit = Math.min(20, Math.max(1, Number(args[0])));
70 }
71 console.log(`Fetching ${limit} transactions...`);
72
73 try {
91 cause: error.cause
92 });
93 return formatErrorMessage(`Failed to fetch transactions: ${error.message}`);
94 }
95}

beeAifrontend.html2 matches

@armadillomike•Updated 2 months ago
378 try {
379 // Send message to API
380 const response = await fetch('/api/chat', {
381 method: 'POST',
382 headers: {
444 try {
445 // Send request to generate image
446 const response = await fetch('/api/generate-image', {
447 method: 'POST',
448 headers: {

ZenChatindex.ts4 matches

@mehran•Updated 2 months ago
94 } as ChatEvent));
95 } catch (error) {
96 console.error("Error fetching message history:", error);
97 }
98
206 return c.json(messages);
207 } catch (error) {
208 console.error("Error fetching messages:", error);
209 return c.json({ error: "Failed to fetch messages" }, 500);
210 }
211});
248
249// This is the entry point for HTTP vals
250export default app.fetch;

manual-fetcher

@miz•Updated 5 days ago

fake-https1 file match

@blazemcworld•Updated 2 weeks ago
simple proxy to fetch http urls using https