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/$%7BsvgDataUrl%7D?q=fetch&page=7&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 14084 results for "fetch"(5018ms)

untitled-8413index.ts7 matches

@chadparker•Updated 1 day ago
20});
21
22// API endpoint to fetch user's vals
23app.get("/api/vals", async c => {
24 try {
32 }
33
34 // Fetch vals from Val Town API
35 const response = await fetch('https://api.val.town/v2/me/vals', {
36 headers: {
37 'Authorization': `Bearer ${apiToken}`,
70
71 } catch (error) {
72 console.error('Error fetching vals:', error);
73 return c.json<ApiResponse<null>>({
74 success: false,
91 }
92
93 const response = await fetch(`https://api.val.town/v1/vals/${valId}`, {
94 headers: {
95 'Authorization': `Bearer ${apiToken}`,
115
116 } catch (error) {
117 console.error('Error fetching val:', error);
118 return c.json<ApiResponse<null>>({
119 success: false,
123});
124
125export default app.fetch;

untitled-8413types.ts1 match

@chadparker•Updated 1 day ago
5 name: string;
6 code?: string; // Not always included in list responses
7 type?: 'http' | 'cron' | 'email' | 'script'; // Need to fetch from individual val
8 privacy: 'public' | 'private' | 'unlisted';
9 author: {

mcp-servermain.ts26 matches

@joshbeckman•Updated 1 day ago
2import { Hono, Context } from 'npm:hono';
3import { SSETransport } from 'npm:hono-mcp-server-sse-transport';
4import { toFetchResponse, toReqRes } from "npm:fetch-to-node";
5import { z } from "npm:zod";
6import lunr from "https://cdn.skypack.dev/lunr";
181 { limit: z.number().optional() },
182 async ({ limit }) => {
183 console.log(`${new Date().toISOString()} Fetching proverbs data`);
184 const proverbs = await fetch("https://www.joshbeckman.org/assets/js/proverbs.json").then((res) => res.json());
185 const results = proverbs
186 .sort(() => Math.random() - 0.5)
187 .slice(0, limit || 100);
188 console.log(`${new Date().toISOString()} Proverbs data fetched`);
189 const data = results.join("\n");
190 return {
198 { limit: z.number().optional(), tag: z.string() },
199 async ({ limit, tag }) => {
200 console.log(`${new Date().toISOString()} Fetching sequences data for tag: ${tag}`);
201 const sequences = await fetch("https://www.joshbeckman.org/assets/js/sequences.json").then((res) => res.json());
202 const results = sequences
203 .filter((seq: any) => seq.topic == tag)
204 .slice(0, limit || 100);
205 console.log(`${new Date().toISOString()} Sequences data fetched`);
206 if (results.length == 0) {
207 return {
222 { id: z.string() },
223 async ({ id }) => {
224 console.log(`${new Date().toISOString()} Fetching sequence data for ID: ${id}`);
225 const sequences = await fetch("https://www.joshbeckman.org/assets/js/sequences.json").then((res) => res.json());
226 const sequence = sequences.find((seq: any) => seq.id == id);
227 console.log(`${new Date().toISOString()} Sequence data fetched`);
228 if (!sequence) {
229 return {
242 { query: z.string(), limit: z.number().optional() },
243 async ({ query, limit }) => {
244 console.log(`${new Date().toISOString()} Fetching tags data for search`);
245 const tags = await fetch("https://www.joshbeckman.org/assets/js/tags.json").then((res) => res.json());
246 const tagsIndex = buildTagsIndex(tags);
247 console.log(`${new Date().toISOString()} Tags search index built`);
268 { tags: z.array(z.string()) },
269 async () => {
270 console.log(`${new Date().toISOString()} Fetching tags data`);
271 const sourceTags = await fetch("https://www.joshbeckman.org/assets/js/tags.json")
272 .then((res) => res.json());
273 console.log(`${new Date().toISOString()} Tags data fetched`);
274 const data = sourceTags.filter((tag) => tags.includes(tag.name)).map((tag) => {
275 return `[${tag.name}](${SITE_URL}${tag.url})`;
285 {},
286 async () => {
287 console.log(`${new Date().toISOString()} Fetching tags data`);
288 const tags = await fetch("https://www.joshbeckman.org/assets/js/tags.json")
289 .then((res) => res.json());
290 const data = tags.sort((a, b) => a.name.localeCompare(b.name)).map((tag) => {
291 return tag.name;
292 }).join("\n");
293 console.log(`${new Date().toISOString()} Tags data fetched`);
294 return {
295 content: [{ type: "text", text: data }]
299 server.tool(
300 "get_post",
301 "Get the full content and metadata of a specific post by its URL. This tool fetches the post data from the site and returns it in a structured format, including title, content, date, tags, author, and more.",
302 { url: z.string() },
303 async ({ url }) => {
304 console.log(`${new Date().toISOString()} Fetching post data for URL: ${url}`);
305 const searchData = await fetch("https://www.joshbeckman.org/assets/js/SearchData.json").then((res) => res.json());
306 const db: Array<Post> = Object.values(searchData).filter(postFilter).map((post) => {
307 post.author_id = post.author_id || "joshbeckman";
310 });
311 const post = db.find((post) => post.url == url || `${SITE_URL}${post.url}` == url);
312 console.log(`${new Date().toISOString()} Post data fetched`);
313 if (!post) {
314 return {
337 console.log(`${new Date().toISOString()} loading search data`);
338 const [searchData, indexCache] = await Promise.all([
339 fetch("https://www.joshbeckman.org/assets/js/SearchData.json").then((res) => res.json()),
340 fetch("https://www.joshbeckman.org/assets/js/lunr-index.json").then((res) => res.json()),
341 ]);
342 console.log(`${new Date().toISOString()} search data loaded`);
450 });
451
452 return toFetchResponse(res);
453 } catch (e) {
454 console.error(e);
501 * This will be exposed as a Val.town HTTP endpoint
502 */
503export default app.fetch;
504

untitled-8413index.html5 matches

@chadparker•Updated 1 day ago
44
45 useEffect(() => {
46 fetchVals();
47 }, []);
48
49 const fetchVals = async () => {
50 try {
51 setLoading(true);
52 const response = await fetch('/api/vals');
53 const result = await response.json();
54
60 }
61 } catch (err) {
62 setError('Failed to fetch vals: ' + err.message);
63 } finally {
64 setLoading(false);
131 ) : null,
132 h('button', {
133 onClick: fetchVals,
134 className: 'bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors'
135 }, 'Try Again')

untitled-8413README.md1 match

@chadparker•Updated 1 day ago
262. **Set the environment variable:**
27 - In your Val Town environment, set `VALTOWN_API_TOKEN` to your API token
28 - The app will automatically fetch and display your vals
29
303. **Access the inspector:**

untitled-6415main.ts1 match

@joshbeckman•Updated 1 day ago
48 ];
49 }
50 let tone = await fetch('https://www.joshbeckman.org/llms/prompts/tone.txt').then(res => res.text());
51 let system = `You are a helpful assistant that provides feedback on blog posts.\n${tone}`;
52 console.log(new Date().toISOString(), "calling for messages");

invest-trackercrypto_cron.tsx2 matches

@samxii777•Updated 1 day ago
13 const url = `https://api.coingecko.com/api/v3/coins/markets`
14 + `?vs_currency=aud&ids=${ids}&sparkline=true`;
15 const coins = await fetch(url, { headers: { "x-cg-demo-api-key": CG } }).then(r => r.json());
16
17 coins.forEach((c: any) => {
23
24 /* 2 â–¸ Stocks + FX via Google Sheet ------------------------------ */
25 const csv = await fetch(SHEET).then(r => r.text());
26 csv.trim().split("\n").slice(1).forEach(line => {
27 let [sym, last, vsLow] = line.split(",").map(s => s.trim());

invest-trackercrypto_low_daily.tsx1 match

@samxii777•Updated 1 day ago
10 + `/market_chart?vs_currency=aud&days=365&interval=daily`;
11
12 const j = await fetch(url).then(r => r.json());
13 const series = Array.isArray(j.prices) ? j.prices : [];
14
11import {Hono} from "npm:hono"
12import {cors} from "npm:hono/cors"
13import {toFetchResponse, toReqRes} from "npm:fetch-to-node"
14import {registerPromptsTools, registerTools} from "./registerTools.ts"
15import {loadConfig} from "./config.ts"
94 })
95
96 // Convert Node.js response back to Fetch response
97 return toFetchResponse(res)
98
99 } catch (error) {
113
114
115export default app.fetch

GlancerpollEnabledStatus.ts1 match

@lightweight•Updated 1 day ago
12
13 // check the boolean to see if a Glancer has enabled the link to start a cobrowsing session
14 const resp = await fetch("/api/cobrowse/" + window.__DEMO_ID__, {
15 method: "GET",
16 headers: {

FetchBasic2 file matches

@ther•Updated 1 week ago

GithubPRFetcher

@andybak•Updated 1 week ago