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=405&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 5985 results for "fetch"(1114ms)

groceriesmain.tsx9 matches

@efoley•Updated 6 months ago
8
9 useEffect(() => {
10 fetchItems();
11 }, []);
12
13 const fetchItems = async () => {
14 const response = await fetch("/items");
15 const data = await response.json();
16 setItems(data);
19 const handleAddItem = async () => {
20 if (newItem.trim() === "") return;
21 await fetch("/items", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },
25 });
26 setNewItem("");
27 fetchItems();
28 };
29
35
36 const removeItem = async (id) => {
37 await fetch(`/items/${id}`, { method: "DELETE" });
38 fetchItems();
39 };
40
41 const clearList = async () => {
42 await fetch("/items", { method: "DELETE" });
43 fetchItems();
44 };
45

createFlashcardsValmain.tsx5 matches

@reginafoley•Updated 6 months ago
16
17 useEffect(() => {
18 fetchCSV();
19 }, []);
20
25 }, [flashcards]);
26
27 const fetchCSV = async () => {
28 const response = await fetch("/csv");
29 const csvText = await response.text();
30 const result = Papa.parse(csvText, { header: false });
57 const formData = new FormData();
58 formData.append("csv", file);
59 const response = await fetch("/upload", {
60 method: "POST",
61 body: formData,
63 if (response.ok) {
64 alert("File uploaded successfully!");
65 fetchCSV();
66 } else {
67 alert("Error uploading file.");

generateDailyTwitterEmailmain.tsx3 matches

@Joelsrubin•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2
3async function fetchTweets(listId: string): Promise<any[]> {
4 const url = `https://news.ycombinator.com/`;
5 const response = await fetch(url);
6 const html = await response.text();
7 console.log(html);
27export default async function(interval: Interval) {
28 const listId = "1359390628841480192";
29 const tweets = await fetchTweets(listId);
30
31 // Sort tweets by likes and get top 10

anthropicCachingmain.tsx6 matches

@stevekrouse•Updated 6 months ago
30 setLoading(prev => ({ ...prev, [operation]: true }));
31 try {
32 const response = await fetch(`/run?operation=${operation}`, {
33 method: "POST",
34 headers: {
138}
139
140async function fetchContent(): Promise<string> {
141 const response = await fetch("https://www.gutenberg.org/cache/epub/1342/pg1342.txt");
142 const text = await response.text();
143
151 const MODEL_NAME = "claude-3-5-sonnet-20240620";
152
153 const bookContent = await fetchContent();
154 const startTime = Date.now();
155
187 const MODEL_NAME = "claude-3-5-sonnet-20240620";
188
189 const bookContent = await fetchContent();
190 const startTime = Date.now();
191
226 const MODEL_NAME = "claude-3-5-sonnet-20240620";
227
228 const bookContent = await fetchContent();
229 const questions = [
230 "What is the title of this novel?",

wallpapermain.tsx5 matches

@Phaeris•Updated 6 months ago
4
5 try {
6 const response = await fetch(url);
7
8 if (!response.ok) {
13 const firstImageUrl = "https://cn.bing.com" + data.images[0].url;
14 // 第三步:请求该图片的实际内容
15 const imageResponse = await fetch(firstImageUrl);
16
17 if (!imageResponse.ok) {
18 throw new Error(`Failed to fetch image! status: ${imageResponse.status}`);
19 }
20
26 });
27 } catch (error) {
28 console.error("Error fetching data:", error);
29 return new Response(JSON.stringify({ error: "Failed to fetch data" }), {
30 status: 500,
31 headers: {

lastloginmain.tsx2 matches

@elliotbraem•Updated 6 months ago
94 tokenUrl.searchParams.set("state", store.state);
95
96 const tokenResp = await fetch(tokenUrl.toString());
97 if (!tokenResp.ok) {
98 throw new Error(await tokenResp.text());
103 };
104
105 const resp = await fetch("https://lastlogin.io/userinfo", {
106 headers: {
107 Authorization: `Bearer ${access_token}`,

iosMobileConfigMultipleWebClipmain.tsx3 matches

@g•Updated 6 months ago
314 if (iconChoice === 'default') {
315 const domain = new URL(url).hostname;
316 const response = await fetch(`/favicon?domain=${encodeURIComponent(domain)}`);
317 const blob = await response.blob();
318 iconBase64 = await convertToBase64(blob);
426 }
427
428 const response = await fetch(`https://www.google.com/s2/favicons?domain=${domain}&sz=256`);
429 const favicon = await response.arrayBuffer();
430
434});
435
436export default app.fetch;

markdown_downloadmain.tsx13 matches

@taras•Updated 6 months ago
145 transcript += arr.map(({ text }) => text).join("\n\n");
146 } catch (e) {
147 transcript = `Failed to fetch transcript ${e}\n`;
148 }
149 let header = "";
153 + y.description + "\n</div>\n\n";
154 } catch (e) {
155 header = `Failed to fetch youtube metadata: ${e}\n`;
156 }
157 return header + "\n" + transcript;
203
204 let html = action.htmlContent;
205 let fetch_response;
206 if (!html) {
207 fetch_response = await fetch(url.toString(), {
208 method: req.method,
209 headers: new Headers({
212 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
213 "Accept-Language": "en-US,en;q=0.5",
214 "Sec-Fetch-Site": "cross-site",
215 "Sec-Fetch-Mode": "navigate",
216 "Sec-Fetch-User": "?1",
217 "Sec-Fetch-Dest": "document",
218 "Referer": "https://www.google.com/",
219 "sec-ch-ua": `"Not A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"`,
225 });
226
227 console.log(fetch_response);
228
229 html = await fetch_response.text();
230 }
231 let title = "";
243 let markdown_extended = markdown + "\n\n" + url;
244
245 if (fetch_response && Math.floor(fetch_response.status / 200) * 200 != 200 || markdown === "") {
246 const jina_url = `https://r.jina.ai/${url.toString()}`;
247 console.log(`jina fallback:${jina_url}`);
248 const fallback_fetch_response = await fetch(jina_url);
249 markdown_extended = await fallback_fetch_response.text();
250 }
251 if (req.headers.get("Accept")?.includes("text/html")) {

selfDestructmain.tsx2 matches

@codemore•Updated 6 months ago
1import ValTown from "https://esm.sh/@valtown/sdk@0.22.0";
2import { fetchValInfo } from "https://esm.town/v/pomdtr/fetchValInfo?v=2";
3
4export async function selfDestruct(importMetaUrl: string) {
5 const { id } = await fetchValInfo(importMetaUrl);
6 const { vals } = new ValTown();
7

Kinopio_Get_User_Spacesmain.tsx1 match

@pketh•Updated 6 months ago
18const getSpaces = async () => {
19 const options = requestOptions({ method: "GET" });
20 const response = await fetch(`${apiHost}/user/spaces`, options);
21 const data = await response.json();
22 const spaceNames = data.map(space => space.name);

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago