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=500&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 7880 results for "fetch"(780ms)

getJsonAndRenderAsImageREADME.md3 matches

@ashryanio•Updated 7 months ago
20## How it works
21
221. Fetching the JSON:
23
24 - The client-side React component makes a fetch request to "/image".
25 - This request is handled by our server function.
26
485. Client-side handling:
49
50 - The fetch request in the React component receives the Response.
51 - We call `response.json()` to parse the JSON object from the Response.
52

hackerNewsDigestmain.tsx8 matches

@workingpleasewait•Updated 7 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
8 const stories = await Promise.all(
9 storyIds.slice(0, count).map(async (id: number) => {
10 const storyResponse = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
11 return storyResponse.json();
12 }),
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);
123 const newStories = await fetchStories("new", 5);
124 const showStories = await fetchStories("show", 3);
125 const askStories = await fetchStories("ask", 3);
126 const jobStories = await fetchStories("job", 3);
127
128 const emailContent = createEmailContent(topStories, newStories, showStories, askStories, jobStories);

OpenAImain.tsx1 match

@It_FITS_Marketing•Updated 7 months ago
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
13 * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.

stockAPImain.tsx4 matches

@pete•Updated 7 months ago
3const ALPHA_VANTAGE_API_KEY = "your_api_key_here"; // Replace with your actual API key
4
5async function fetchStockData(symbol: string) {
6 const apiUrl =
7 `https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${ALPHA_VANTAGE_API_KEY}`;
8 const response = await fetch(apiUrl);
9 const data = await response.json();
10
39
40 try {
41 const stockData = await fetchStockData(symbol);
42 return new Response(JSON.stringify(stockData, null, 2), {
43 headers: { "Content-Type": "application/json" },
61 }
62
63 fetchStockData(symbol).then(stockData => {
64 console.log(`Symbol: ${stockData.symbol}`);
65 console.log(`Price: $${stockData.price.toFixed(2)}`);

uptimemain.tsx2 matches

@cjpais•Updated 7 months ago
11 const start = performance.now();
12 try {
13 const res = await fetch(url);
14 end = performance.now();
15 status = res.status;
22 } catch (e) {
23 end = performance.now();
24 reason = `couldn't fetch: ${e}`;
25 ok = false;
26 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);

csvToSqliteUploadermain.tsx1 match

@vawogbemi•Updated 7 months ago
34 setIsUploading(true);
35 try {
36 const response = await fetch("/upload", {
37 method: "POST",
38 body: formData,

placeholderKittenImagesmain.tsx1 match

@ashryanio•Updated 7 months ago
136 try {
137 console.log(`Generating image with dimensions: ${width}x${height}`);
138 const imageResponse = await fetch(imageGenerationUrl);
139 console.log(`Response status: ${imageResponse.status}`);
140

FanFicScrapermain.tsx2 matches

@willthereader•Updated 7 months ago
13 console.log(`Submitting URL for scraping: ${url}`);
14 try {
15 const response = await fetch("/scrape", {
16 method: "POST",
17 headers: { "Content-Type": "application/json" },
107 const startTime = Date.now();
108 try {
109 const response = await fetch(
110 `https://app.scrapingbee.com/api/v1/?api_key=${apiKey}&url=${
111 encodeURIComponent(url)

getBlobAndRenderAsImageREADME.md3 matches

@ashryanio•Updated 7 months ago
12## How it works
13
141. Fetching the blob:
15
16 - The client-side React component makes a fetch request to "/image".
17 - This request is handled by our server function.
18
405. Client-side handling:
41
42 - The fetch request in the React component receives the Response.
43 - We call `response.blob()` to get a Blob object from the Response.
44

blob_adminmain.tsx2 matches

@ashryanio•Updated 7 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago