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/$%7Bart_info.art.src%7D?q=fetch&page=35&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 8156 results for "fetch"(2828ms)

live-reloadclient.ts2 matches

@stevekrouse•Updated 4 days ago
6 */
7async function registerLongPoll({ pageLoadedAt }: { pageLoadedAt: number }) {
8 const { lastUpdatedAt, status } = await (await fetch("/__lastUpdatedAt")).json();
9 if (lastUpdatedAt > pageLoadedAt) {
10 window.location.href = `https://reload.val.run?${new URLSearchParams({ url: window.location.href })}`;
28 return;
29 }
30 const resp = await fetch(targetURL);
31 if (resp.ok) {
32 window.location.href = targetURL;

live-reload-demomain.tsx1 match

@stevekrouse•Updated 4 days ago
15
16// Enable live reloading
17export default liveReload(app.fetch, import.meta.url);

GitHub-trending-summarysummarize-to-email1 match

@ynonp•Updated 4 days ago
4import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from "npm:node-html-markdown";
5
6const html = await fetch("https://github.com/trending").then(r => r.text());
7
8const { window: { document } } = new JSDOM(html);

minemain.tsx1 match

@yassinreg•Updated 4 days ago
25
26 try {
27 const response = await fetch(window.location.href, {
28 method: "POST",
29 body: formData,

sqliteExplorerAppmain.tsx4 matches

@skynocover•Updated 4 days ago
1/** @jsxImportSource npm:hono/jsx **/
2
3import { 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});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

Lairmain.tsx14 matches

@Get•Updated 4 days ago
2// A more declarative and extensible multi-agent platform structure.
3
4import { fetch } from "https://esm.town/v/std/fetch"; // Assuming Val Town environment
5
6// --- Core Interfaces ---
296}
297
298// Agent 2: Fetch External Data (modified for new signature)
299async function fetchAgent(
300 input: AgentInput<{ url?: string }>, // Optionally allow URL via input
301 context: AgentContext,
305 const url = payload?.url || "https://jsonplaceholder.typicode.com/todos/1"; // Default URL
306
307 log('INFO', 'FetchAgent', `Start fetching data from ${url}`);
308 try {
309 const resp = await fetch(url);
310 if (!resp.ok) {
311 throw new Error(`Workspace failed: Server responded with status ${resp.status} ${resp.statusText}`);
313 const data = await resp.json();
314
315 log('SUCCESS', 'FetchAgent', `Data fetched successfully`, { url, responseStatus: resp.status });
316 return { mandateId, correlationId: taskId, payload: { data } };
317 } catch (e: any) {
318 log('ERROR', 'FetchAgent', `Workspaceing failed`, e);
319 return { mandateId, correlationId: taskId, payload: { data: null }, error: e.message };
320 }
325const analysisWorkflow: WorkflowDefinition = {
326 id: "basicAnalysis",
327 description: "Summarizes user text and fetches placeholder data.",
328 steps: [
329 {
335 },
336 {
337 id: "step2_fetchData",
338 agent: "fetcher",
339 // No input mapping needed if the agent uses defaults or doesn't require specific input from workflow state
340 input: {} // Explicitly empty
345 outputMapping: { // Define the final output structure
346 finalSummary: { source: "step1_summarize", field: "summary" },
347 externalData: { source: "step2_fetchData", field: "data"},
348 }
349};
358// Register agents
359agentRegistry.register("summarizer", summarizerAgent);
360agentRegistry.register("fetcher", fetchAgent);
361// Register more agents...
362// agentRegistry.register("sentimentAnalyzer", sentimentAgent);
410
411 try {
412 const res = await fetch(window.location.pathname, {
413 method: 'POST',
414 headers: { 'Content-Type': 'application/json' },
430
431 } catch (err) {
432 resultBox.textContent = 'Fetch Error: ' + err.message;
433 resultBox.className = 'error';
434 logBox.textContent = 'Failed to communicate with the backend.';

ca_highlightsmain.tsx2 matches

@exgenesis•Updated 4 days ago
4// 1. if we've never queued for *today*, build queue via selectHighlights().
5// ‑ if no highlights, insert sentinel row into posted_tweets (tweet_id = "dummy‑YYYY‑MM‑DD").
6// 2. fetch any queued tweets scheduled within the next 15 min window and post them.
7// -----------------------------------------------------------------------------
8// env secrets:
74 ),
75 );
76 const res = await fetch(url, {
77 method: "POST",
78 headers: { "content-type": "application/json", ...authHeader },

hn_job_analyzerhnService.ts30 matches

@prashamtrivedi•Updated 4 days ago
1export async function fetchHiringPosts(postId?: number): Promise<any[]> {
2 try {
3 // If no post ID is provided, find the latest "Who is hiring" post
6 }
7
8 // Fetch the post data
9 const post = await fetchItem(postId);
10
11 // Fetch all comments
12 const comments = await Promise.all(
13 (post.kids || []).map(async (commentId: number) => {
14 return await fetchItem(commentId);
15 })
16 );
19 return comments.filter(comment => !comment.deleted && !comment.dead);
20 } catch (error) {
21 console.error('Error fetching hiring posts:', error);
22 throw error;
23 }
24}
25
26export async function fetchWantToBeHiredPosts(postId?: number): Promise<any[]> {
27 try {
28 // If no post ID is provided, find the latest "Who wants to be hired" post
31 }
32
33 // Fetch the post data
34 const post = await fetchItem(postId);
35
36 // Fetch all comments
37 const comments = await Promise.all(
38 (post.kids || []).map(async (commentId: number) => {
39 return await fetchItem(commentId);
40 })
41 );
44 return comments.filter(comment => !comment.deleted && !comment.dead);
45 } catch (error) {
46 console.error('Error fetching want to be hired posts:', error);
47 throw error;
48 }
49}
50
51export async function fetchFreelancerPosts(postId?: number): Promise<any[]> {
52 try {
53 // If no post ID is provided, find the latest "Freelancer? Seeking Freelancer?" post
56 }
57
58 // Fetch the post data
59 const post = await fetchItem(postId);
60
61 // Fetch all comments
62 const comments = await Promise.all(
63 (post.kids || []).map(async (commentId: number) => {
64 return await fetchItem(commentId);
65 })
66 );
69 return comments.filter(comment => !comment.deleted && !comment.dead);
70 } catch (error) {
71 console.error('Error fetching freelancer posts:', error);
72 throw error;
73 }
74}
75
76// Helper function to fetch an item from the HN API
77async function fetchItem(id: number): Promise<any> {
78 const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
79 return await response.json();
80}
84 try {
85 // First, get the latest stories
86 const response = await fetch('https://hacker-news.firebaseio.com/v0/askstories.json');
87 const storyIds = await response.json();
88
89 // Fetch the latest 50 stories to find the most recent "Who is hiring" post
90 const stories = await Promise.all(
91 storyIds.slice(0, 50).map(async (id: number) => {
92 return await fetchItem(id);
93 })
94 );
116 try {
117 // First, get the latest stories
118 const response = await fetch('https://hacker-news.firebaseio.com/v0/askstories.json');
119 const storyIds = await response.json();
120
121 // Fetch the latest 50 stories to find the most recent "Who wants to be hired" post
122 const stories = await Promise.all(
123 storyIds.slice(0, 50).map(async (id: number) => {
124 return await fetchItem(id);
125 })
126 );
148 try {
149 // First, get the latest stories
150 const response = await fetch('https://hacker-news.firebaseio.com/v0/askstories.json');
151 const storyIds = await response.json();
152
153 // Fetch the latest 50 stories to find the most recent "Freelancer? Seeking Freelancer?" post
154 const stories = await Promise.all(
155 storyIds.slice(0, 50).map(async (id: number) => {
156 return await fetchItem(id);
157 })
158 );

discord-botapi-server.js3 matches

@boucher•Updated 4 days ago
73 res.json({ success: true, data: messages });
74 } catch (error) {
75 console.error('Error fetching messages:', error);
76 res.status(500).json({ success: false, error: error.message });
77 }
92 res.json({ success: true, data: links });
93 } catch (error) {
94 console.error('Error fetching links:', error);
95 res.status(500).json({ success: false, error: error.message });
96 }
103 res.json({ success: true, data: categories });
104 } catch (error) {
105 console.error('Error fetching categories:', error);
106 res.status(500).json({ success: false, error: error.message });
107 }

discord-botval-town-cron.js4 matches

@boucher•Updated 4 days ago
1import { fetchAndStoreDMs } from './discord-client.js';
2import 'dotenv/config';
3
11 */
12export default async function cronHandler() {
13 console.log('Starting scheduled Discord DM fetch...');
14 try {
15 await fetchAndStoreDMs();
16 return { success: true, message: 'Successfully fetched and stored DMs' };
17 } catch (error) {
18 console.error('Error in cron job:', error);

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago