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=432&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 8384 results for "fetch"(1727ms)

cerebras_codermain.tsx1 match

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

photoEditingAIAppmain.tsx2 matches

@roysarajit143•Updated 3 months ago
23 const formData = new FormData();
24 formData.append('image', file);
25 const response = await fetch('/upload', {
26 method: 'POST',
27 body: formData
32
33 const generateAIImage = async (prompt) => {
34 const response = await fetch('/generate', {
35 method: 'POST',
36 headers: { 'Content-Type': 'application/json' },

originalTomatoLynxmain.tsx1 match

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

cerebras_codermain.tsx1 match

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

reactPinterestClonemain.tsx9 matches

@Ronu12_05•Updated 3 months ago
116
117 useEffect(() => {
118 async function fetchPosts() {
119 try {
120 const response = await fetch('/get-posts');
121 if (!response.ok) {
122 throw new Error('Failed to fetch posts');
123 }
124 const fetchedPosts = await response.json();
125 setPosts(fetchedPosts);
126 } catch (error) {
127 setError(error.message);
128 console.error('Failed to fetch posts', error);
129 }
130 }
131 fetchPosts();
132 }, []);
133
134 const handlePostSubmit = async (newPost) => {
135 try {
136 const response = await fetch('/create-post', {
137 method: 'POST',
138 headers: { 'Content-Type': 'application/json' },
154 const handleDeletePost = async (postId) => {
155 try {
156 const response = await fetch(`/delete-post/${postId}`, { method: 'DELETE' });
157
158 if (!response.ok) {

audioManagermain.tsx3 matches

@Foji•Updated 3 months ago
1
2import { OpenAI } from "https://esm.town/v/yawnxyz/OpenAI";
3import { fetch } from "https://esm.town/v/std/fetch";
4
5import { getUrl } from "https://esm.town/v/yawnxyz/download";
180
181
182 // Function to fetch audio data and return as ArrayBuffer
183 async getAudioBuffer(url) {
184 const response = await fetch(url);
185 return await response.arrayBuffer();
186 }

filemain.tsx3 matches

@loading•Updated 3 months ago
149
150 const generateQRCode = async (id: string) => {
151 const qrcode = await (await fetch(`https://loading-generateqr.web.val.run/?peer=${id}`)).json();
152 setQrcode(qrcode.base64Image);
153 };
406});
407
408// self.addEventListener('fetch', (event) => {
409// event.respondWith(
410// caches.match(event.request).then((response) => {
411// return response || fetch(event.request);
412// })
413// );

bombCycloneOutageTrackermain.tsx3 matches

@andreterron•Updated 3 months ago
25
26 useEffect(() => {
27 async function fetchData() {
28 const response = await fetch("/outages");
29 const json = await response.json();
30 let firstEntry: { i: number; time: number; date: Date } = { i: -1, time: Date.now(), date: new Date() };
92 setOutageData(data);
93 }
94 fetchData();
95 }, []);
96

website_Summarizermain.tsx16 matches

@arfan•Updated 3 months ago
52 }, []);
53
54 const fetchAndSummarize = async () => {
55 if (!siteUrl) {
56 setError("Please enter a valid site URL");
63 setSiteInfo(null);
64 setProgress(10);
65 console.log("Starting fetchAndSummarize");
66
67 try {
68 // 1) Fetch site data
69 setProgress(30);
70 console.log("Fetching site details");
71 const siteResponse = await fetch(`/site-data?url=${encodeURIComponent(siteUrl)}`);
72 if (!siteResponse.ok) {
73 throw new Error(`Failed to fetch site details: ${siteResponse.statusText}`);
74 }
75 const siteData = await siteResponse.json();
76 setSiteInfo(siteData);
77 console.log("Site details fetched", siteData);
78
79 // 2) Summarize site content
80 setProgress(60);
81 console.log("Sending summary request");
82 const summaryResponse = await fetch("/summarize", {
83 method: "POST",
84 headers: {
102 console.log("Summarization complete");
103 } catch (err) {
104 console.error("Fetch Error:", err);
105 setError(`Error: ${err.message}`);
106 setLoading(false);
111 const handleKeyDown = (event) => {
112 if (event.key === "Enter" && !loading) {
113 fetchAndSummarize();
114 }
115 };
138 />
139 <button
140 onClick={fetchAndSummarize}
141 disabled={loading}
142 className="bg-orange-500 text-white p-3 rounded-r-lg hover:bg-orange-600 disabled:opacity-50 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-orange-500"
271 // Scrapes the HTML and returns minimal metadata
272 if (request.method === "GET" && pathname === "/site-data") {
273 console.log("Fetching site data");
274 const siteUrl = searchParams.get("url");
275 if (!siteUrl) {
281
282 try {
283 // Fetch the HTML from the site
284 const siteResponse = await fetch(siteUrl);
285 if (!siteResponse.ok) {
286 throw new Error(`Failed to fetch site: ${siteResponse.statusText}`);
287 }
288 const siteHtml = await siteResponse.text();
310 });
311 } catch (error) {
312 console.error("Error fetching site data:", error);
313 return new Response(JSON.stringify({ error: error.message }), {
314 status: 500,

epgmain.tsx6 matches

@taoji•Updated 3 months ago
1const Config = {
2 repository: 'e.erw.cc',
3 FETCH_TIMEOUT: 3000, // 3 seconds timeout
4 CACHE_DURATION: 1000 * 60 * 60 // 1 hour cache
5};
8const EPG_CACHE = new Map();
9
10async function timeoutFetch(request, timeout = Config.FETCH_TIMEOUT) {
11 const controller = new AbortController();
12 const timeoutId = setTimeout(() => controller.abort(), timeout);
13
14 try {
15 const response = await fetch(request, {
16 signal: controller.signal,
17 headers: {
18 'User-Agent': 'ValTown EPG Fetcher',
19 'Accept': 'application/json'
20 }
66
67 try {
68 const res = await timeoutFetch(new Request(`https://github.com/celetor/epg/releases/download/${tag}/112114.json`, request));
69 const data = await res.json();
70
96 return makeRes(JSON.stringify(program_info), 200, { 'content-type': 'application/json' });
97 } catch (error) {
98 console.error('EPG Fetch Error:', error);
99 return makeRes(JSON.stringify({
100 date,

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago