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=539&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 8299 results for "fetch"(1853ms)

spotifyPlaylistSearchmain.tsx2 matches

@trob•Updated 7 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 7 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 7 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 7 months ago
1Migrated from folder: fanficSearcher/ScrapingBeeAttempt/ThreadmarkLISTFetcher2

ThreadmarkLISTFetchermain.tsx16 matches

@willthereader•Updated 7 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: {
156async function getThreadmarkUrls(baseUrl, apiKey) {
157 versionLogger(import.meta.url);
158 console.log(`[START] Threadmark URL fetch for base URL: ${baseUrl}`);
159 const startTime = Date.now();
160
173
174 const requestStartTime = Date.now();
175 const response = await fetch(scrapingBeeUrl);
176 console.log(
177 `Response received. Status: ${response.status}, Headers: ${
246 allThreadmarks = allThreadmarks.concat(threadmarks);
247 } catch (error) {
248 console.error(`[ERROR] Exception during fetching or parsing for category ${category}:`);
249 console.error(`[ERROR] Error name: ${error.name}`);
250 console.error(`[ERROR] Error message: ${error.message}`);
256 const totalDuration = Date.now() - startTime;
257 console.log(
258 `[END] Finished fetching threadmarks for all categories in ${totalDuration} ms. Total threadmarks found: ${allThreadmarks.length}`,
259 );
260
349 try {
350 const { url, chapterTitles } = await request.json();
351 console.log(`[INFO] Received request to fetch threadmarks for URL: ${url}`);
352 const threadmarks = await getThreadmarkUrls(url, apiKey);
353 console.log(`[INFO] Retrieved ${threadmarks.length} threadmarks`);
368 }
369 } catch (error) {
370 console.error("[ERROR] Error in threadmark fetching or comparison:");
371 console.error(`[ERROR] Error name: ${error.name}`);
372 console.error(`[ERROR] Error message: ${error.message}`);
374 return new Response(
375 JSON.stringify({
376 error: `Error fetching threadmarks: ${error.message}`,
377 stack: error.stack,
378 }),
393 <meta charset="UTF-8">
394 <meta name="viewport" content="width=device-width, initial-scale=1.0">
395 <title>Threadmark Fetcher and Comparator</title>
396 <style>${CSS}</style>
397 </head>

currencyTransactionmain.tsx4 matches

@wallek•Updated 7 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3async function fetchJSON(url: string) {
4 const response = await fetch(url);
5 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
6 return response.json();
21// View at https://wallek-currencyTransaction.val.run?target=gbp&root=eur&amount=100
22export default async function(req: Request): Promise<Response> {
23 const { rates } = await fetchJSON(`https://api.exchangerate-api.com/v4/latest/USD`);
24
25 // USD is the base currency, so we need to add it manually

getAirtableDataAPImain.tsx4 matches

@stnkvcs•Updated 7 months ago
4const tableName = Deno.env.get("AIRTABLE_TABLE_NAME");
5
6async function fetchAirtableData(uid: string) {
7 if (!airtableApiKey || !baseId || !tableName) {
8 throw new Error("Missing Airtable environment variables");
10
11 const url = `https://api.airtable.com/v0/${baseId}/${tableName}?filterByFormula=UID%3D%22${encodeURIComponent(uid)}%22`;
12 const response = await fetch(url, {
13 headers: {
14 Authorization: `Bearer ${airtableApiKey}`,
53 }
54
55 const record = await fetchAirtableData(uid);
56
57 if (!record) {
73 return Response.json({ data }, { headers });
74 } catch (error) {
75 console.error("Error fetching Airtable data:", error);
76 return new Response("Internal Server Error", { status: 500 });
77 }

HTMX_templatemain.tsx2 matches

@deepfates•Updated 7 months ago
53
54 var formBody = "userGroup=&email=" + encodeURIComponent(formInput.value);
55 fetch(event.target.action, {
56 method: "POST",
57 body: formBody,
80 .catch(error => {
81 // check for cloudflare error
82 if (error.message === "Failed to fetch") {
83 rateLimit();
84 return;

wordcountermain.tsx1 match

@yawnxyz•Updated 7 months ago
169app.get("/", (c) => c.html(html));
170
171export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;

argsummain.tsx4 matches

@martinbowling•Updated 7 months ago
146 try {
147 const url = '${url}';
148 const response = await fetch(url, {
149 method: 'POST',
150 headers: {
156 if (!response.ok) {
157 let errorJson = await response.json();
158 console.error('Fetch Error:', errorJson);
159 showError('Error fetching data: ' + (errorJson.message || 'Unknown error'));
160 return;
161 }
359app.get("/", (c) => c.html(html));
360
361export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago