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/$%7Burl%7D?q=fetch&page=1043&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 13349 results for "fetch"(1493ms)

twitterRecentMentionsmain.tsx3 matches

@charmaine•Updated 8 months ago
1// This val fetches recent tweets about @SnapAR or Lens Studio
2// Updated to use Social Data instead of Twitter API
3
12 return retResponse(data.tweets);
13 } catch (error) {
14 console.error("Error fetching posts:", error);
15 return new Response(JSON.stringify({ error: "Failed to fetch posts", details: error.message }), {
16 status: 500,
17 headers: { "Content-Type": "application/json" },

socialDataUpdatemain.tsx4 matches

@charmaine•Updated 8 months ago
1// This val fetches recent tweets about @SnapAR or Lens Studio, removes duplicates,
2// and displays them as embedded tweets with preview images on a dark background.
3// Updated to use Social Data instead of Twitter API
5import { socialDataSearch } from "https://esm.town/v/stevekrouse/socialDataSearch?v=5";
6
7// This val fetches recent social media posts about @SnapAR or Lens Studio using socialDataSearch,
8// and displays them as embedded posts with preview images on a dark background.
9
15 return retResponse(data.tweets);
16 } catch (error) {
17 console.error("Error fetching posts:", error);
18 return new Response(JSON.stringify({ error: "Failed to fetch posts", details: error.message }), {
19 status: 500,
20 headers: { "Content-Type": "application/json" },

youtubeSearchResultsmain.tsx3 matches

@trob•Updated 8 months ago
14 setLoading(true);
15 try {
16 const response = await fetch(`/search?q=${encodeURIComponent(query)}`);
17 if (!response.ok) {
18 throw new Error(`HTTP error! status: ${response.status}`);
88 try {
89 const searchUrl = `https://www.youtube.com/results?search_query=${encodeURIComponent(query)}`;
90 const response = await fetch(searchUrl);
91 if (!response.ok) {
92 throw new Error(`YouTube search failed: ${response.statusText}`);
123 } catch (error) {
124 console.error("Search error:", error);
125 return new Response(JSON.stringify({ error: "An error occurred while fetching search results." }), {
126 headers: { "Content-Type": "application/json" },
127 status: 500,

weekly_mortgage_ratesmain.tsx4 matches

@bleikamp•Updated 8 months ago
12const FRED_API_KEY = process.env.FRED_API_KEY;
13
14// Function to fetch rate data from FRED API
15async function getRateData(seriesId: string): Promise<RateData> {
16 const url =
17 `https://api.stlouisfed.org/fred/series/observations?series_id=${seriesId}&api_key=${FRED_API_KEY}&file_type=json&sort_order=desc&limit=2`;
18
19 const response = await fetch(url);
20 const data = await response.json();
21
34 };
35 } else {
36 throw new Error(`Failed to fetch data for series ${seriesId}`);
37 }
38}
39
40// Function to fetch all rate data
41async function getAllRateData(): Promise<RateData[]> {
42 const seriesIds = ["MORTGAGE30US", "SOFR30DAYAVG"];

smoothBluePanthermain.tsx1 match

@stevekrouse•Updated 8 months ago
12 const updateHtml = async () => {
13 try {
14 const response = await fetch("/api/modify", {
15 method: "POST",
16 headers: { "Content-Type": "application/json" },

ThreadmarkLISTFetcher2main.tsx15 matches

@willthereader•Updated 8 months ago
11 loading = true;
12 updateUI();
13 console.log(`Fetching threadmarks for URL: ${url}`);
14 try {
15 result = await fetchThreadmarksFromServer(url, chapterTitles);
16 } catch (error) {
17 console.log(`Error occurred while fetching threadmarks: ${error.message}`);
18 result = { error: error.message };
19 }
26 root.innerHTML = `
27 <div>
28 <h1>Threadmark Fetcher and Comparator</h1>
29 <form id="threadmarkForm">
30 <div>
33 id="urlInput"
34 value="${url}"
35 placeholder="Enter URL to fetch threadmarks"
36 required
37 />
46 </div>
47 <button type="submit" ${loading ? "disabled" : ""}>
48 ${loading ? "Fetching..." : "Fetch and Compare Threadmarks"}
49 </button>
50 </form>
139}
140
141async function fetchThreadmarksFromServer(url, chapterTitles) {
142 const response = await fetch("/api/threadmarks", {
143 method: "POST",
144 headers: {
171
172 const requestStartTime = Date.now();
173 const response = await fetch(scrapingBeeUrl);
174 const requestDuration = Date.now() - requestStartTime;
175
206 allThreadmarks = allThreadmarks.concat(threadmarks);
207 } catch (error) {
208 console.error(`[ERROR] Exception during fetching or parsing for category ${category}:`);
209 console.error(`[ERROR] Error name: ${error.name}`);
210 console.error(`[ERROR] Error message: ${error.message}`);
217 const totalDuration = Date.now() - startTime;
218 console.log(
219 `[END] Finished fetching threadmarks for all categories in ${totalDuration} ms. Total threadmarks found: ${allThreadmarks.length}`,
220 );
221
323 try {
324 const { url, chapterTitles } = await request.json();
325 // console.log(`[INFO] Received request to fetch threadmarks for URL: ${url}`);
326 const threadmarks = await getThreadmarkUrls(url, apiKey);
327 console.log(`[INFO] Retrieved ${threadmarks.length} threadmarks`);
342 }
343 } catch (error) {
344 console.error("[ERROR] Error in threadmark fetching or comparison:");
345 console.error(`[ERROR] Error name: ${error.name}`);
346 console.error(`[ERROR] Error message: ${error.message}`);
348 return new Response(
349 JSON.stringify({
350 error: `Error fetching threadmarks: ${error.message}`,
351 stack: error.stack,
352 }),
367 <meta charset="UTF-8">
368 <meta name="viewport" content="width=device-width, initial-scale=1.0">
369 <title>Threadmark Fetcher and Comparator</title>
370 <style>${CSS}</style>
371 </head>

spotifyPlaylistSearchmain.tsx2 matches

@trob•Updated 8 months ago
10 const searchPlaylists = async () => {
11 try {
12 const response = await fetch(`/search?q=${encodeURIComponent(query)}`);
13 if (!response.ok) {
14 throw new Error(`HTTP error! status: ${response.status}`);
121 const url = `https://itunes.apple.com/search?term=${encodeURIComponent(query)}&entity=playlist&limit=20`;
122
123 const response = await fetch(url);
124
125 if (!response.ok) {

effortlessCrimsonDolphinmain.tsx2 matches

@stevekrouse•Updated 8 months ago
1import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity";
9 const since = lastRunAt ? Math.floor(lastRunAt.getTime() / 1000) : 0;
10 url.searchParams.append("query", query + " since_time:" + since);
11 const { tweets } = await fetchJSON(url.toString(), {
12 bearer: Deno.env.get("SOCIAL_DATA_API_KEY"),
13 });

multiUserChatwithLLMmain.tsx12 matches

@trob•Updated 8 months ago
12
13 useEffect(() => {
14 fetchMessages();
15 getOrCreateUsername();
16 const intervalId = setInterval(() => {
17 fetchNewMessages();
18 checkReset();
19 }, 1000); // Poll every second
32 let storedUsername = localStorage.getItem("chatUsername");
33 if (!storedUsername) {
34 const response = await fetch("/username");
35 const data = await response.json();
36 storedUsername = data.username;
40 };
41
42 const fetchMessages = async () => {
43 const response = await fetch("/messages");
44 const data = await response.json();
45 setMessages(data);
49 };
50
51 const fetchNewMessages = async () => {
52 const response = await fetch(`/new-messages?lastId=${lastMessageIdRef.current}`);
53 const newMessages = await response.json();
54 if (newMessages.length > 0) {
59
60 const checkReset = async () => {
61 const response = await fetch(`/check-reset?token=${resetTokenRef.current}`);
62 const data = await response.json();
63 if (data.reset) {
74 setInput("");
75
76 const response = await fetch("/send", {
77 method: "POST",
78 headers: { "Content-Type": "application/json" },
81
82 if (response.ok) {
83 fetchNewMessages(); // Immediately fetch new messages after sending
84 }
85 };
86
87 const resetChat = async () => {
88 const response = await fetch("/reset", { method: "POST" });
89 if (response.ok) {
90 setMessages([]);
164 await sqlite.execute(`INSERT INTO ${KEY}_messages_${SCHEMA_VERSION} (role, content, username) VALUES (?, ?, ?)`, ["user", message, username]);
165
166 // Fetch recent context
167 const contextResult = await sqlite.execute(
168 `SELECT role, content, username FROM ${KEY}_messages_${SCHEMA_VERSION}

ThreadmarkLISTFetcher2README.md1 match

@willthereader•Updated 8 months ago
1Migrated from folder: fanficSearcher/ScrapingBeeAttempt/ThreadmarkLISTFetcher2

GithubPRFetcher

@andybak•Updated 1 day ago

proxiedfetch1 file match

@jayden•Updated 2 days ago