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=356&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"(1288ms)

tikTokVideoDownloadermain.tsx7 matches

@SowrovCIV•Updated 3 months ago
11 const downloadRef = useRef(null);
12
13 const fetchTikTokVideo = async () => {
14 // Reset previous state
15 setDownloadLink('');
20 try {
21 // Use a more reliable, free TikTok video download service
22 const response = await fetch(`https://api.tikmate.app/api/lookup`, {
23 method: 'POST',
24 headers: {
36 setError('');
37
38 // Fetch video blob for direct download
39 const videoResponse = await fetch(data.download_url);
40 const blob = await videoResponse.blob();
41 setVideoData(blob);
42 } else {
43 setError('Could not fetch video. Please check the URL and try again.');
44 }
45 } catch (err) {
92 />
93 <button
94 onClick={fetchTikTokVideo}
95 style={styles.button}
96 disabled={!videoUrl || loading}
104 {loading && (
105 <div style={styles.loadingSpinner}>
106 <span>🔄 Fetching video...</span>
107 </div>
108 )}

translatormain.tsx4 matches

@AIWB•Updated 3 months ago
244 const formData = new FormData();
245 formData.append("audio", blob, "recording.wav");
246 const response = await fetch("/transcribe", { method: "POST", body: formData });
247 if (response.ok) {
248 const result = await response.text();
284 const language2Value = document.getElementById("language2").value;
285
286 const response = await fetch("/translate", {
287 method: "POST",
288 headers: { "Content-Type": "application/json" },
326
327 if (text && voice) {
328 const response = await fetch('/generate-speech', {
329 method: 'POST',
330 headers: { 'Content-Type': 'application/json' },
453});
454
455export default app.fetch;

sqlite_adminmain.tsx1 match

@genco•Updated 3 months ago
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });

getLemmyJwtmain.tsx1 match

@AIWB•Updated 3 months ago
7 const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
8 let client = new LemmyHttp(`https://${instance}`, {
9 fetchFunction: fetch,
10 });
11 try {

API_URLmain.tsx4 matches

@awhitter•Updated 3 months ago
102}
103
104// Val Town HTTP Endpoint for Airtable → Framer Fetch
105export default async function (req: Request): Promise<Response> {
106 // Setup CORS Headers for Framer Fetch compatibility
107 const headers = new Headers({
108 "Access-Control-Allow-Origin": "*",
123 const airtableTableId = await val.secrets.AIRTABLE_TABLE_ID;
124
125 // Fetch all records with pagination
126 let allRecords: AirtableRecord[] = [];
127 let offset: string | undefined;
133 }
134
135 const airtableResp = await fetch(url.toString(), {
136 headers: {
137 Authorization: `Bearer ${airtableApiKey}`,

codeOnValTownmain.tsx3 matches

@AIWB•Updated 3 months ago
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;

codeOnValTownREADME.md6 matches

@AIWB•Updated 3 months ago
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;

contentTemplateAppmain.tsx19 matches

@awhitter•Updated 3 months ago
53
54 useEffect(() => {
55 fetchContent();
56 }, []);
57
58 const fetchContent = async () => {
59 try {
60 const response = await fetch("/api/content");
61 const data = await response.json();
62 if (data.records) {
63 setContent(data.records);
64 } else {
65 throw new Error("Failed to fetch content");
66 }
67 setLoading(false);
68 } catch (error) {
69 console.error("Error fetching content:", error);
70 setLoading(false);
71 }
99 const analyzeContent = async (item: AirtableRecord) => {
100 try {
101 const response = await fetch("/api/analyze", {
102 method: "POST",
103 headers: {
260
261 try {
262 const response = await fetch(airtableUrl, {
263 headers: {
264 'Authorization': `Bearer ${apiToken}`,
274 return new Response(JSON.stringify(data), { headers });
275 } catch (error) {
276 console.error("Error fetching Airtable data:", error);
277 return new Response(JSON.stringify({ error: "Error fetching data from Airtable" }), {
278 status: 500,
279 headers
368// Example 2: Making an API call to /api/content endpoint
369/*
370async function fetchContent() {
371 try {
372 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content');
373 const data = await response.json();
374 console.log('Content:', data);
375 // Process the data as needed
376 } catch (error) {
377 console.error('Error fetching content:', error);
378 }
379}
380
381fetchContent();
382*/
383
427*/
428
429// Example 5: Using the endpoint in Framer with fetch
430/*
431// In your Framer project, create a new code component and use the following code:
433import { Data, animate, Override, Animatable } from "framer"
434
435// This function fetches the content from the API
436async function fetchContent() {
437 try {
438 const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content')
439 const data = await response.json()
440 return data.records
441 } catch (error) {
442 console.error('Error fetching content:', error)
443 return []
444 }
450
451 Data.useEffect(() => {
452 fetchContent().then(setContent)
453 }, [])
454

aimain.tsx3 matches

@goode_bye•Updated 3 months ago
694
695 // just launch it, don't wait for the result
696 // const taskRunResponse = await fetch(`${URL}/taskrun`, {
697 const taskRunResponse = fetch(`${URL}/taskrun`, {
698 method: "POST",
699 headers: {
785}
786
787export default app.fetch;
788export { ai, ModelProvider, modelProvider, test };

aiREADME.md1 match

@goode_bye•Updated 3 months ago
12
13 try {
14 const response = await fetch(url);
15 const data = await response.json();
16 return data;

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago