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=393&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 7885 results for "fetch"(1415ms)

fascinatingBrownKrillmain.tsx1 match

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

scl_2024main.tsx10 matches

@stanley•Updated 3 months ago
38}
39
40async function fetchAndCacheData() {
41 try {
42 console.log("Fetching URL:", url);
43 const response = await fetch(url, {
44 headers: {
45 "User-Agent":
72 return bootstrapData;
73 } catch (error) {
74 console.error("Error fetching and caching data:", error);
75 const cachedData = await blob.getJSON(cacheKey);
76 if (cachedData) {
79 ...cachedData.data,
80 _cachedAt: cachedData.timestamp,
81 _cacheNotice: "This is cached data. Live fetching failed.",
82 };
83 }
87
88async function getFullData() {
89 const data = await fetchAndCacheData();
90 const donationGoal = data.checkoutLink.checkout_link_data.donation_goal;
91 const totalRaised = data.donationGoalProgress;
107
108async function getDonationProgress() {
109 const data = await fetchAndCacheData();
110 const donationGoal = data.checkoutLink.checkout_link_data.donation_goal;
111 return Response.json({
121
122async function getCheckoutDetails() {
123 const data = await fetchAndCacheData();
124 return Response.json({
125 checkoutTitle: data.checkoutTitle,
130
131async function getCampaignInfo() {
132 const data = await fetchAndCacheData();
133 const linkData = data.checkoutLink.checkout_link_data;
134 return Response.json({
141
142async function getScrapedData() {
143 const data = await fetchAndCacheData();
144 const donationGoal = data.checkoutLink.checkout_link_data.donation_goal;
145 const totalRaised = data.donationGoalProgress;

blob_adminmain.tsx23 matches

@dave_smith•Updated 3 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));

libgenopdsmain.tsx7 matches

@mintexists•Updated 3 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { load } from "npm:cheerio";
3
11 url.searchParams.set("q", query);
12
13 const html = await fetch(url).then(r => r.text());
14
15 const $ = load(html);
95}
96
97async function fetchMetadataLibgenRs(
98 url: string | undefined,
99 identifier: string | undefined = undefined,
102 const origin = new URL(url as string).origin;
103
104 const html = await fetch(url as string).then(r => r.text());
105
106 const $ = load(html);
150}
151
152async function fetchMetadataLibgenLi(
153 url: string | undefined,
154 identifier: string | undefined = undefined,
157 const origin = new URL(url as string).origin;
158
159 const html = await fetch(url as string).then(r => r.text());
160
161 const $ = load(html);
266 const results = await search(query);
267 const libgenMetadata = await Promise.all(results.map(async (result) => {
268 const libgenMetadata = await fetchMetadataLibgenRs(result.libgenRsURL, result.url, result.language?.[0]);
269 return {
270 ...result,

lockmain.tsx2 matches

@postpostscript•Updated 3 months ago
1import { sleep } from "https://deno.land/x/sleep/mod.ts";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { parentReference } from "https://esm.town/v/stevekrouse/parentReference";
4import { searchParams } from "https://esm.town/v/stevekrouse/searchParams";
83
84export async function makeRequest(id: string, method: "release" | "acquire", params): Promise<LockResponse> {
85 return fetchJSON(
86 `https://dlock.univalent.net/lock/${id}/${method}?${searchParams(params)}`,
87 );

zyloxAIChatAppmain.tsx1 match

@gigmx•Updated 3 months ago
22
23 try {
24 const response = await fetch("/chat", {
25 method: "POST",
26 headers: { "Content-Type": "application/json" },

compassionateBlackCatfishmain.tsx2 matches

@gigmx•Updated 3 months ago
164
165 try {
166 const response = await fetch(API_URL, {
167 method: "POST",
168 headers: {
229
230 try {
231 const response = await fetch(API_URL, {
232 method: "POST",
233 headers: {

stellarCrimsonPandamain.tsx1 match

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

cerebras_codermain.tsx1 match

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

gistFetchermain.tsx4 matches

@tgrecojs•Updated 3 months ago
20 getFileData(fileName),
21 );
22const fetcher = () => {
23 const gistUrl = "https://api.github.com/gists/979a41207cb789364e2c78181bafc331";
24
25 return fetch(gistUrl)
26 .then(response => {
27 if (!response.ok) throw new Error("Failed to fetch data from GitHub Gist.");
28 return response.json();
29 })
44};
45
46export default fetcher;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago