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=355&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 7881 results for "fetch"(1067ms)

regexWordSearchPagemain.tsx4 matches

@jrunning•Updated 3 months ago
15
16 useEffect(() => {
17 async function fetchWords() {
18 try {
19 const response = await fetch('https://raw.githubusercontent.com/dwyl/english-words/refs/heads/master/words.txt');
20 if (!response.ok) throw new Error('Failed to fetch words');
21 const text = await response.text();
22 const wordList = text.split('\n')
38 }
39 }
40 fetchWords();
41 }, []);
42

githubParsermain.tsx23 matches

@yawnxyz•Updated 3 months ago
243
244
245 async function fetchFileTypes(repoUrl) {
246 const response = await fetch('/file-types', {
247 method: 'POST',
248 headers: { 'Content-Type': 'application/json' },
375 try {
376 console.log('Sending request to /parse endpoint...');
377 const response = await fetch('/parse', {
378 method: 'POST',
379 headers: {
444 try {
445 const ignoredPatterns = parseIgnoredPatterns();
446 const fileTypes = await fetchFileTypes(repoUrl);
447 displayFileTypeSelector(fileTypes, ignoredPatterns);
448 } catch (error) {
500 }
501
502 console.log(`Fetching content for ${owner}/${repo}`);
503 const content = await fetchRepositoryContent(owner, repo, branch, ignoredPatterns, selectedTypes);
504 const tokenCounts = await countTokens(content);
505
587}
588
589async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) {
590 // First, try to get the default branch or use the specified branch
591 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
592 const repoInfoResponse = await fetch(repoInfoUrl, {
593 headers: {
594 'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
601 throw new Error(`Repository not found or not accessible: ${owner}/${repo}`);
602 }
603 throw new Error(`Failed to fetch repository info: ${repoInfoResponse.statusText}`);
604 }
605
608
609 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`;
610 const response = await fetch(apiUrl, {
611 headers: {
612 'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
617 if (!response.ok) {
618 if (response.status === 404) {
619 throw new Error(`Failed to fetch repository content. The ${defaultBranch} branch might not exist.`);
620 }
621 throw new Error(`GitHub API request failed: ${response.statusText}`);
645 for (const file of files) {
646 try {
647 const fileContent = await fetchFileContent(owner, repo, file.path, defaultBranch);
648 content += `File: ${file.path}\n\n${fileContent}\n\n`;
649 } catch (error) {
650 console.error(`Failed to fetch content for ${file.path}: ${error.message}`);
651 content += `File: ${file.path}\n\nError: Failed to fetch content\n\n`;
652 }
653 }
661}
662
663async function fetchFileContent(owner, repo, path, branch) {
664 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
665 const response = await fetch(apiUrl, {
666 headers: {
667 'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
671
672 if (!response.ok) {
673 throw new Error(`Failed to fetch file content: ${response.statusText}`);
674 }
675
792}
793
794// Add new endpoint to handle file type fetching
795app.post("/file-types", async (c) => {
796 try {
822async function getRepositoryFileTypes(owner, repo, specifiedBranch = null) {
823 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
824 const repoInfoResponse = await fetch(repoInfoUrl, {
825 headers: {
826 'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
830
831 if (!repoInfoResponse.ok) {
832 throw new Error(`Failed to fetch repository info: ${repoInfoResponse.statusText}`);
833 }
834
837
838 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`;
839 const response = await fetch(apiUrl, {
840 headers: {
841 'Authorization': `token ${Deno.env.get("GITHUB_API_KEY")}`,
863}
864
865// Export app.fetch for Val Town, otherwise export app — this is only for hono apps
866export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
867

appmain.tsx2 matches

@RIKKAEBI•Updated 3 months ago
13
14 useEffect(() => {
15 fetch("/likes")
16 .then(async (res) => await res.json() as Like)
17 .then(data => setLikes(data.likes));
22 confetti();
23 setLikes((prev) => prev + 1);
24 fetch("/like", { method: "POST" }).catch(console.error);
25 });
26

URLReceiverurlCrawlerComponent4 matches

@willthereader•Updated 3 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 }

OpenRouterChatCompletion_Testmain.tsx1 match

@rozek•Updated 3 months ago
11
12 try {
13 const CompletionResponse = await fetch('https://rozek-openrouterchatcompletion.web.val.run/', {
14 method: 'POST',
15 headers:{ 'Content-Type':'application/json' },

cerebras_codermain.tsx1 match

@Shashank_3•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

imageUploadPerMinuteWebsitemain.tsx13 matches

@Chishti78studi•Updated 3 months ago
31 }, []);
32
33 // Fetch images and comments when the component first loads or page changes
34 useEffect(() => {
35 fetchImages();
36 fetchComments();
37 }, [currentPage]);
38
39 // Function to retrieve images from the server with pagination
40 const fetchImages = async () => {
41 try {
42 const response = await fetch(`/images?page=${currentPage}`);
43 const data = await response.json();
44 setImages(data.images);
45 setTotalPages(data.totalPages);
46 } catch (err) {
47 setError("Could not fetch images");
48 console.error("Image fetch error:", err);
49 }
50 };
51
52 // Function to retrieve comments from the server
53 const fetchComments = async () => {
54 try {
55 const response = await fetch('/comments');
56 const data = await response.json();
57 setComments(data);
58 } catch (err) {
59 setError("Could not fetch comments");
60 console.error("Comments fetch error:", err);
61 }
62 };
111 formData.append('username', username);
112
113 const response = await fetch('/upload', {
114 method: 'POST',
115 body: formData
128
129 // Refresh images after upload
130 await fetchImages();
131
132 // Reset upload states

jarvisPrototypemain.tsx1 match

@pashaabhi•Updated 3 months ago
96 if (status === "Jarvis activated. How can I help?") {
97 try {
98 const response = await fetch("/chat", {
99 method: "POST",
100 body: JSON.stringify({

OpenRouterChatCompletionmain.tsx2 matches

@rozek•Updated 3 months ago
66
67 if (stream == true) {
68 const OpenRouterStream = await fetch(
69 'https://openrouter.ai/api/v1/chat/completions',{
70 method:'POST',
88 })
89 } else {
90 const OpenRouterCompletion = await fetch(
91 'https://openrouter.ai/api/v1/chat/completions',{
92 method:'POST',

lastloginmain.tsx2 matches

@AIWB•Updated 3 months ago
94 tokenUrl.searchParams.set("state", store.state);
95
96 const tokenResp = await fetch(tokenUrl.toString());
97 if (!tokenResp.ok) {
98 throw new Error(await tokenResp.text());
103 };
104
105 const resp = await fetch("https://lastlogin.net/userinfo", {
106 headers: {
107 Authorization: `Bearer ${access_token}`,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago