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=85&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 8238 results for "fetch"(920ms)

JimeluStevensApp.tsx17 matches

@luke_f•Updated 1 week ago
82 const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
83
84 // Fetch images from backend instead of blob storage directly
85 useEffect(() => {
86 // Set default background color in case image doesn't load
89 }
90
91 // Fetch avatar image
92 fetch("/api/images/stevens.jpg")
93 .then((response) => {
94 if (response.ok) return response.blob();
103 });
104
105 // Fetch wood background
106 fetch("/api/images/wood.jpg")
107 .then((response) => {
108 if (response.ok) return response.blob();
129 }, []);
130
131 const fetchMemories = useCallback(async () => {
132 setLoading(true);
133 setError(null);
134 try {
135 const response = await fetch(API_BASE);
136 if (!response.ok) {
137 throw new Error(`HTTP error! status: ${response.status}`);
154 }
155 } catch (e) {
156 console.error("Failed to fetch memories:", e);
157 setError(e.message || "Failed to fetch memories.");
158 } finally {
159 setLoading(false);
162
163 useEffect(() => {
164 fetchMemories();
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
176
177 try {
178 const response = await fetch(API_BASE, {
179 method: "POST",
180 headers: { "Content-Type": "application/json" },
188 setNewMemoryTags("");
189 setShowAddForm(false);
190 await fetchMemories();
191 } catch (e) {
192 console.error("Failed to add memory:", e);
199
200 try {
201 const response = await fetch(`${API_BASE}/${id}`, {
202 method: "DELETE",
203 });
205 throw new Error(`HTTP error! status: ${response.status}`);
206 }
207 await fetchMemories();
208 } catch (e) {
209 console.error("Failed to delete memory:", e);
231
232 try {
233 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234 method: "PUT",
235 headers: { "Content-Type": "application/json" },
240 }
241 setEditingMemory(null);
242 await fetchMemories();
243 } catch (e) {
244 console.error("Failed to update memory:", e);

notionboxdsync.ts2 matches

@jclem•Updated 1 week ago
38 const rssURL = process.env.RSS_URL!;
39
40 const rss = await fetch(rssURL).then(res => {
41 if (res.status !== 200) {
42 throw new Error("Failed to fetch RSS");
43 }
44

BingImageOfDayindex.tsx7 matches

@wolf•Updated 1 week ago
3import { blob } from "https://esm.town/v/std/blob";
4import { backupBingImage } from "./backupImage.tsx";
5import { fetchBingImage } from "./fetchBingImage.tsx";
6
7const app = new Hono();
51app.get("/", async (c) => {
52 try {
53 // Use our helper function to fetch the current Bing image
54 const response = await fetchBingImage();
55 if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
56
64 });
65 } catch (error) {
66 return c.json({ error: "Failed to fetch current Bing image" }, 500);
67 }
68});
84 path: "/",
85 method: "GET",
86 description: "Fetches the current Bing Image of the Day.",
87 response: "JPEG image with headers `Content-Type: image/jpeg`.",
88 },
96 path: "/get/:date",
97 method: "GET",
98 description: "Fetches a saved Bing Image of the Day for a specific date.",
99 urlParams: "date - format: MM-DD-YYYY",
100 response: "JPEG image or JSON error if not found.",
120
121// This is the entry point for HTTP vals
122export default app.fetch;

Glancerresets2 matches

@bradnoble•Updated 1 week ago
16 const lastRunAt = new Date(lastRun?.date);
17 const content = lastRun?.content;
18 const fetchURL = [
19 "https://" + subdomain + ".val.run",
20 lastRun?.path,
42 // (note the x-blob-key header)
43 if (content != "default" && diffInMinutes > .5) {
44 const response = await fetch(fetchURL, {
45 method: "POST",
46 headers: {

Glancerhelpers.ts3 matches

@bradnoble•Updated 1 week ago
28 const origin = parsedUrl.origin;
29
30 // Fetch the HTML from the URL
31 const response = await fetch(url);
32 const html = await response.text();
33
62
63 // Verify the favicon exists
64 const faviconResponse = await fetch(faviconUrl, { method: "HEAD" });
65
66 if (!faviconResponse.ok) {

practicalAquaWaspmain.tsx2 matches

@stevekrouse•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react */
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
3
4const exampleJSX = <p>Hello, World!</p>;
5
6console.log(
7 await fetchText("https://esm.town/v/moe/HonoReactTailwindStarter@48-deptest/frontend/index.tsx", {
8 headers: {
9 "User-Agent": "", // can't include Deno, which on Val Town it would by default

practicalAquaWaspREADME.md1 match

@stevekrouse•Updated 1 week ago
5It doesn't do as much as other transpilers (such as esm.sh, such as rewriting `npm:` imports, etc). We may add that capability in the future. For now, if you want your npm imports to run in the browser, use `https://esm.sh/package` instead of `npm:package`.
6
7The below script demonstrates this transiplation behavior by fetching its own source code (`import.meta.url`) with the user agent of a browser. You can uncoment the line setting the browser agent if you want to see the difference in the output. Or you could just load this val's module URL in your browser to see the untranspiled TS.
8
9As of July 23, 2024, this is the code that determines when esm.town transpiles or not:

filterValsmain.tsx2 matches

@nbbaier•Updated 1 week ago
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4 const token = Deno.env.get("valtown");
5 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6 headers: { Authorization: `Bearer ${token}` },
7 });

filterValsmain.tsx2 matches

@dcm31•Updated 1 week ago
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2console.log('hi')
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4 const token = Deno.env.get("valtown");
5 const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6 headers: { Authorization: `Bearer ${token}` },
7 });

valreadmegeneratormain.tsx1 match

@dcm31•Updated 1 week ago
42
43 try {
44 const response = await fetch(`/generate-readme/${user}/${val}`);
45
46 if (!response.ok) {

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago