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=239&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 2440 results for "fetch"(560ms)

Windsurfprojectcontext8 matches

@toowired•Updated 2 months ago
51
52 useEffect(() => {
53 fetchState();
54 }, []);
55
56 /**
57 * Fetches the current state from the server
58 */
59 const fetchState = async () => {
60 setIsLoading(true);
61 setError(null);
62 try {
63 const response = await fetch("/api/state");
64 if (!response.ok) throw new Error("Failed to fetch state");
65 const data = await response.json();
66 setState(data);
80 setError(null);
81 try {
82 const response = await fetch("/api/state", {
83 method: "POST",
84 headers: { "Content-Type": "application/json" },
86 });
87 if (!response.ok) throw new Error("Failed to update state");
88 await fetchState();
89 } catch (err) {
90 setError(err.message);
565 if (webhookUrl) {
566 try {
567 await fetch(webhookUrl, {
568 method: "POST",
569 headers: { "Content-Type": "application/json" },

prolificPinkGullmain.ts1 match

@chris_st•Updated 2 months ago
7countPath(app);
8
9export default app.fetch;

trackESMContentmain.tsx3 matches

@shouser•Updated 2 months ago
10const TABLE_NAME = `${KEY}_versions_v1`;
11
12async function fetchContent(url: string) {
13 const response = await fetch(url);
14 return await response.text();
15}
30
31 for (const url of URLS) {
32 const content = await fetchContent(url);
33 const latestVersion = await sqlite.execute(
34 `SELECT blob_key FROM ${TABLE_NAME} WHERE url = ? ORDER BY timestamp DESC LIMIT 1`,

prolificPinkGulltest.ts1 match

@chris_st•Updated 2 months ago
11const supabase = createClient(supabaseUrl, supabaseKey)
12
13// Disable prefetch as it is not supported for "Transaction" pool mode
14export const client = postgres(connectionString, { prepare: false })

blob_admin_migratedmain.tsx23 matches

@shouser•Updated 2 months ago
234 const [isDragging, setIsDragging] = useState(false);
235
236 const fetchBlobs = useCallback(async () => {
237 setLoading(true);
238 try {
239 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240 const data = await response.json();
241 setBlobs(data);
242 } catch (error) {
243 console.error("Error fetching blobs:", error);
244 } finally {
245 setLoading(false);
248
249 useEffect(() => {
250 fetchBlobs();
251 }, [fetchBlobs]);
252
253 const handleSearch = (e) => {
264 setBlobContentLoading(true);
265 try {
266 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267 const content = await response.text();
268 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
269 setEditContent(content);
270 } catch (error) {
271 console.error("Error fetching blob content:", error);
272 } finally {
273 setBlobContentLoading(false);
278 const handleSave = async () => {
279 try {
280 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281 method: "PUT",
282 body: editContent,
290 const handleDelete = async (key) => {
291 try {
292 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293 setBlobs(blobs.filter(b => b.key !== key));
294 if (selectedBlob && selectedBlob.key === key) {
307 const key = `${searchPrefix}${file.name}`;
308 formData.append("key", encodeKey(key));
309 await fetch("/api/blob", { method: "POST", body: formData });
310 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311 setBlobs([newBlob, ...blobs]);
315 }
316 }
317 fetchBlobs();
318 };
319
329 try {
330 const fullKey = `${searchPrefix}${key}`;
331 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332 method: "PUT",
333 body: "",
344 const handleDownload = async (key) => {
345 try {
346 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347 const blob = await response.blob();
348 const url = window.URL.createObjectURL(blob);
363 if (newKey && newKey !== oldKey) {
364 try {
365 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366 const content = await response.blob();
367 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368 method: "PUT",
369 body: content,
370 });
371 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373 if (selectedBlob && selectedBlob.key === oldKey) {
383 const newKey = `__public/${key}`;
384 try {
385 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386 const content = await response.blob();
387 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388 method: "PUT",
389 body: content,
390 });
391 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393 if (selectedBlob && selectedBlob.key === key) {
402 const newKey = key.slice(9); // Remove "__public/" prefix
403 try {
404 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405 const content = await response.blob();
406 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407 method: "PUT",
408 body: content,
409 });
410 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412 if (selectedBlob && selectedBlob.key === key) {
826});
827
828export default lastlogin((request: Request) => app.fetch(request));

sqliteExplorerAppmain.tsx4 matches

@shouser•Updated 2 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/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 })));

OpenTowniesystem_prompt.txt2 matches

@AIWB•Updated 2 months ago
155 * The main App component is rendered on the client.
156 * No server-side-specific code should be included in the App.
157 * Use fetch to communicate with the backend server portion.
158 */
159function App() {
178 * Server-only code
179 * Any code that is meant to run on the server should be included in the server function.
180 * This can include endpoints that the client side component can send fetch requests to.
181 */
182export default async function server(request: Request): Promise<Response> {

OpenTownieindex1 match

@AIWB•Updated 2 months ago
26
27 try {
28 const response = await fetch("/", {
29 method: "POST",
30 headers: { "authorization": "Bearer " + bearerToken },

OpenTowniegenerateCode1 match

@AIWB•Updated 2 months ago
26
27export async function generateCodeAnthropic(messages: Message[]): Promise<ValResponse | null> {
28 const system = await (await fetch(`${import.meta.url.split("/").slice(0, -1).join("/")}/system_prompt.txt`)).text();
29
30 const openai = new OpenAI({

URLReceiverurlCrawlerComponent4 matches

@willthereader•Updated 2 months ago
75 try {
76 console.log(`Checking URL: ${url}`);
77 const response = await fetch(url, {
78 method: "GET",
79 headers: {
137 private async extractUrlsFromPage(url: string): Promise<string[]> {
138 try {
139 const response = await fetch(url);
140 if (!response.ok) {
141 console.log(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
142 return [];
143 }
193 return uniqueUrls;
194 } catch (error) {
195 console.error(`Error fetching ${url}:`, error);
196 return [];
197 }

fetchPaginatedData2 file matches

@nbbaier•Updated 5 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago