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/$2?q=fetch&page=52&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 13587 results for "fetch"(1711ms)

untitled-2689main.tsx13 matches

@wahobd•Updated 4 days ago
604 const triggerTelegramInteraction = async (chatId) => {
605 try {
606 const response = await fetch("/handle-telegram-interaction", {
607 method: "POST",
608 headers: { "Content-Type": "application/json" },
621 };
622
623 const fetchUserBalance = async () => {
624 let userId = null;
625 let isTelegramEnv = false;
674 if (userId) {
675 try {
676 const response = await fetch(`/get-balance?uid=${userId}`);
677 if (!response.ok) {
678 try {
699 }
700 } catch (error) {
701 console.error("Failed to fetch or process balance:", error.toString());
702 setBalance("Error");
703 }
704 } else {
705 console.error("User ID could not be determined for balance fetching.");
706 setBalance("--.--");
707 }
727 window.Telegram.WebApp.ready();
728 }
729 fetchUserBalance();
730 } else if (isTelegramWebAppPresent) {
731 console.log(
732 "Telegram script present, but user data not immediately available or ready() pending. Setting timeout for balance fetch.",
733 );
734 if (window.Telegram.WebApp.ready) {
735 window.Telegram.WebApp.ready();
736 }
737 scriptLoadTimeoutId = setTimeout(fetchUserBalance, 300);
738 } else {
739 console.log("Not in Telegram environment. Proceeding as web user for balance fetch.");
740 fetchUserBalance();
741 }
742 }
878 setShowSpinner(true);
879
880 const response = await fetch("/save-credentials", {
881 method: "POST",
882 headers: { "Content-Type": "application/json" },
1880 const sendActualTelegramAPIMessage = async (botToken, chatId, text, parseMode = "Markdown") => {
1881 try {
1882 const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
1883 method: "POST",
1884 headers: { "Content-Type": "application/json" },
2190 if (confirm('Are you sure you want to unban this user?')) {
2191 try {
2192 const response = await fetch('/unban-telegram-user', {
2193 method: 'POST',
2194 headers: { 'Content-Type': 'application/json' },

proxiedfetchmain.tsx2 matches

@jayden•Updated 4 days ago
1import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
2
3export default async function (req: Request): Promise<Response> {
28
29 try {
30 const upstream = await proxiedFetch(target, init);
31 // Stream status, statusText, headers, and body back to the client
32 return new Response(upstream.body, {

leglmain.tsx11 matches

@join•Updated 4 days ago
264 <textarea id="legal-task-query" name="legalTaskQuery" placeholder="E.g., 'Identify all clauses related to termination for cause.' or 'Summarize the key obligations of Party A.'">${escapedQuery}</textarea>
265
266 <label for="doc-url">Document URL (Optional - content will be fetched):</label>
267 <input type="text" id="doc-url" name="documentUrl" value="${escapedUrl}" placeholder="https://example.com/legal-document.html">
268
491 inputSourceDescription = \`URL: \${urlValue}\`;
492 formData.append('documentUrl', urlValue);
493 addStatusMessage(\`Fetching and processing content from URL: \${urlValue}\`, 'progress');
494 }
495 formData.append('inputSourceDescription', inputSourceDescription);
498 try {
499 // The Val itself acts as the API endpoint
500 const response = await fetch(window.location.pathname + '?format=json', {
501 method: 'POST',
502 // FormData sets Content-Type automatically
568 const { OpenAI } = await import("https://esm.town/v/std/openai");
569 const { z } = await import("npm:zod"); // For potential future robust input validation on server
570 const { fetch } = await import("https://esm.town/v/std/fetch");
571 const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
572
692 documentText = input.documentText;
693 } else if (input.documentUrl) {
694 log.push({ agent: ingestionAgent, type: "step", message: `Fetching from URL: ${input.documentUrl}` });
695 try {
696 // Basic fetch, consider adding User-Agent, timeout, error handling, content-type checking
697 const response = await fetch(input.documentUrl, {
698 headers: { "Accept": "text/plain, text/html, application/pdf" },
699 }); // Accept PDF too
702 const contentType = response.headers.get("content-type") || "";
703 if (contentType.includes("application/pdf")) {
704 log.push({ agent: ingestionAgent, type: "info", message: "Fetched PDF from URL. Extracting text..." });
705 const pdfBuffer = await response.arrayBuffer();
706 documentText = await extractPdfTextNative(
715 } else { // Assume text-like
716 const text = await response.text();
717 if (!text || text.trim().length === 0) throw new Error("Fetched content is empty or not text.");
718 log.push({ agent: ingestionAgent, type: "info", message: `Fetched ~${text.length} characters from URL.` });
719 documentText = text;
720 }
721 } catch (error) {
722 const errorMessage = `Failed to fetch or process URL ${input.documentUrl}: ${error.message}`;
723 log.push({ agent: ingestionAgent, type: "error", message: errorMessage });
724 documentText = null;

cerebras_coderv3index.ts1 match

@etomberg391•Updated 4 days ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

TownieuseUser.tsx4 matches

@PrincessJossy•Updated 4 days ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
13
14 const res = await fetch(userEndpoint);
15 const data = await res.json();
16 if (!res.ok) {
33
34 useEffect(() => {
35 fetchData();
36 }, []);
37
38 return { data, loading, error, refetch: fetchData };
39}
40

TownieuseProject.tsx5 matches

@PrincessJossy•Updated 4 days ago
9 const [error, setError] = useState(null);
10
11 const fetchData = async () => {
12 try {
13 const projectEndpoint = new URL(PROJECT_ENDPOINT, window.location.origin);
17 if (branchId) filesEndpoint.searchParams.append("branchId", branchId);
18
19 const { project } = await fetch(projectEndpoint).then((res) =>
20 res.json()
21 );
22 const { files } = await fetch(filesEndpoint).then((res) => res.json());
23
24 setData({ project, files });
34 useEffect(() => {
35 if (!projectId) return;
36 fetchData();
37 }, [projectId, branchId]);
38
39 return { data, loading, error, refetch: fetchData };
40}
41

TownieuseProjects.tsx4 matches

@PrincessJossy•Updated 4 days ago
8 const [error, setError] = useState(null);
9
10 const fetchData = async () => {
11 try {
12 const res = await fetch(ENDPOINT);
13 const data = await res.json();
14 if (!res.ok) {
32
33 useEffect(() => {
34 fetchData();
35 }, []);
36
37 return { data, loading, error, refetch: fetchData };
38}
39

TownieuseCreateProject.tsx1 match

@PrincessJossy•Updated 4 days ago
19 setError(null);
20 try {
21 const res = await fetch(ENDPOINT, {
22 method: "POST",
23 headers: {

TownieuseCreateBranch.tsx1 match

@PrincessJossy•Updated 4 days ago
12 setData(null);
13 setError(null);
14 const res = await fetch(ENDPOINT, {
15 method: "POST",
16 body: JSON.stringify({

TownieuseBranches.tsx4 matches

@PrincessJossy•Updated 4 days ago
7 const [loading, setLoading] = useState(true);
8
9 const fetchData = async () => {
10 const endpoint = new URL(ENDPOINT, window.location.origin);
11 endpoint.searchParams.append("projectId", projectId);
12
13 const res = await fetch(endpoint)
14 .then(res => res.json());
15 setData(res.branches);
19 useEffect(() => {
20 if (!projectId) return;
21 fetchData();
22 }, [projectId]);
23
24 return { data, loading, refetch: fetchData };
25}

FetchBasic2 file matches

@ther•Updated 9 hours ago

GithubPRFetcher

@andybak•Updated 3 days ago