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/$2?q=fetch&page=1027&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 13397 results for "fetch"(1486ms)

animalInfoIngpracticalBlushAlbatrossmain.tsx20 matches

@junhoca•Updated 7 months ago
25
26 useEffect(() => {
27 fetchComments();
28 fetchRating();
29 }, []);
30
31 const fetchComments = async () => {
32 const response = await fetch(`/${type}/${item.id}/comments`);
33 if (response.ok) {
34 const data = await response.json();
37 };
38
39 const fetchRating = async () => {
40 const response = await fetch(`/${type}/${item.id}/rating`);
41 if (response.ok) {
42 const data = await response.json();
46
47 const addComment = async () => {
48 const response = await fetch(`/${type}/${item.id}/comments`, {
49 method: 'POST',
50 headers: { 'Content-Type': 'application/json' },
53 if (response.ok) {
54 setNewComment('');
55 fetchComments();
56 }
57 };
58
59 const addRating = async (newRating) => {
60 const response = await fetch(`/${type}/${item.id}/rating`, {
61 method: 'POST',
62 headers: { 'Content-Type': 'application/json' },
108
109 useEffect(() => {
110 fetchInitialData();
111 fetchFavorites();
112 }, [page]);
113
114 const fetchInitialData = async () => {
115 const response = await fetch(`/search?type=${page}&query=`);
116 if (response.ok) {
117 const data = await response.json();
123 };
124
125 const fetchFavorites = async () => {
126 const response = await fetch("/favorites");
127 if (response.ok) {
128 const data = await response.json();
133 const handleSearch = async (e) => {
134 if (e.key === "Enter" || e.type === "click") {
135 const response = await fetch(`/search?type=${page}&query=${encodeURIComponent(search)}`);
136 if (response.ok) {
137 const data = await response.json();
146 const toggleFavorite = async (item, type) => {
147 const method = favorites[type].some(fav => fav.id === item.id) ? 'DELETE' : 'POST';
148 const response = await fetch(`/favorites/${type}`, {
149 method,
150 headers: { 'Content-Type': 'application/json' },
152 });
153 if (response.ok) {
154 fetchFavorites();
155 }
156 };
157
158 const addLostPet = async (petData) => {
159 const response = await fetch("/lostPets", {
160 method: "POST",
161 headers: { 'Content-Type': 'application/json' },
163 });
164 if (response.ok) {
165 fetchInitialData();
166 }
167 };

stripeCasualCheckoutDemomain.tsx1 match

@vawogbemi•Updated 7 months ago
11 setLoading(true);
12 try {
13 const response = await fetch("/create-checkout-session", {
14 method: "POST",
15 headers: {

passwordGenmain.tsx1 match

@all•Updated 7 months ago
222 }
223
224 const response = await fetch("/generate", {
225 method: "POST",
226 headers: { "Content-Type": "application/json" },

sendNtifyNotificationmain.tsx2 matches

@jnv•Updated 7 months ago
1import { fetch } from 'https://esm.town/v/std/fetch';
2
3export type NtfyPayload = {
22
23 const body = JSON.stringify({ ...payload, topic });
24 const res = await fetch(server, {
25 method: 'POST',
26 headers: {

fullPageWebsiteScrapermain.tsx14 matches

@willthereader•Updated 7 months ago
55 }
56}
57// Link Fetching Helper
58export class LinkFetcher {
59 static discoveredUrls = new Set();
60 static pageDepths = new Map();
61 static processQueue = [];
62
63 static async fetchLinksFromWebsite(websiteUrl) {
64 console.log(`\nFetching links from website: ${websiteUrl}`);
65 console.log("Initial HTML structure analysis begin");
66 const query = `
79
80 console.log(`Making LSD API request for ${websiteUrl}`);
81 const response = await fetch(
82 `https://lsd.so/api?query=${encodeURIComponent(query)}`,
83 );
84
85 if (!response.ok) {
86 console.log(`Failed to fetch links from ${websiteUrl}`);
87 return [];
88 }
148 const currentBatch = pagesToProcess.splice(0, 10);
149 const batchPromises = currentBatch.map(async (pageUrl) => {
150 console.log(`Fetching links from: ${pageUrl}`);
151 const pageQuery = `
152 SELECT
162
163 console.log(`Making LSD API request for ${pageUrl}`);
164 const response = await fetch(
165 `https://lsd.so/api?query=${encodeURIComponent(pageQuery)}`,
166 );
167
168 if (!response.ok) {
169 console.log(`Failed to fetch links from ${pageUrl}`);
170 return [];
171 }
235 }
236
237 console.log(`Successfully fetched ${allLinks.length} links from ${discoveredPages.size} pages`);
238 return allLinks;
239 }
279 try {
280 console.log(`Attempting HEAD request for: ${url}`);
281 const response = await fetch(url, { method: "HEAD" });
282
283 if (!response.ok) {
284 console.log(`HEAD request failed, attempting GET request for: ${url}`);
285 const getResponse = await fetch(url, { method: "GET" });
286 return { ok: getResponse.ok, status: getResponse.status };
287 }
431 };
432
433 // Fetch all links with progress tracking
434 const links = await LinkFetcher.fetchLinksFromWebsite(websiteUrl);
435 const totalPages = new Set(links.map(link =>
436 new URL(link.link, websiteUrl).origin + new URL(link.link, websiteUrl).pathname

sqliteExplorerAppmain.tsx4 matches

@jaip•Updated 7 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

xmasRedHamstermain.tsx1 match

@trollishka•Updated 7 months ago
28async function getMostPopularPinterestImage(query: string): Promise<string> {
29 const searchUrl = `https://api.pinterest.com/v5/search/pins?query=${encodeURIComponent(query)}&page_size=50&sort_order=popularity`;
30 const response = await fetch(searchUrl, {
31 headers: {
32 "Accept-Language": "en-US",

xmasRedHamstermain.tsx1 match

@stevekrouse•Updated 7 months ago
28async function getMostPopularPinterestImage(query: string): Promise<string> {
29 const searchUrl = `https://api.pinterest.com/v5/search/pins?query=${encodeURIComponent(query)}&page_size=50&sort_order=popularity`;
30 const response = await fetch(searchUrl, {
31 headers: {
32 "Accept-Language": "en-US",

tokencountermain.tsx1 match

@prashamtrivedi•Updated 7 months ago
34 if (modelFamily === "Anthropic" && anthropicApiKey) {
35 try {
36 const response = await fetch("/api/count-tokens", {
37 method: "POST",
38 headers: {

multilingualchatroommain.tsx21 matches

@daisuke•Updated 7 months ago
211 useEffect(() => {
212 if (roomId) {
213 const fetchDefaultUsername = async () => {
214 try {
215 // First, check if there's a username in localStorage
218 setUsername(storedUsername);
219 } else {
220 // If not, fetch a default username from the server
221 const response = await fetch(`/default-username?room=${roomId}`);
222 if (response.ok) {
223 const defaultUsername = await response.text();
234 }
235 } catch (error) {
236 console.error("Error fetching default username:", error);
237 }
238 };
239
240 fetchDefaultUsername();
241 }
242 }, [roomId]);
246 const pollMessages = async () => {
247 try {
248 const response = await fetch(`/messages?room=${roomId}&language=${language}`);
249 if (response.ok) {
250 const newMessages = await response.json();
258 }
259 } catch (error) {
260 console.error("Error fetching messages:", error);
261 }
262 };
263
264 const fetchUsers = async () => {
265 try {
266 const response = await fetch(`/users?room=${roomId}`);
267 if (response.ok) {
268 const userList = await response.json();
270 }
271 } catch (error) {
272 console.error("Error fetching users:", error);
273 }
274 };
275
276 const fetchTypingUsers = async () => {
277 try {
278 const response = await fetch(`/typing-users?room=${roomId}`);
279 if (response.ok) {
280 const typingUsersList = await response.json();
282 }
283 } catch (error) {
284 console.error("Error fetching typing users:", error);
285 }
286 };
287
288 pollMessages();
289 fetchUsers();
290 fetchTypingUsers();
291 const messageIntervalId = setInterval(pollMessages, 2000);
292 const userIntervalId = setInterval(fetchUsers, 5000);
293 const typingIntervalId = setInterval(fetchTypingUsers, 1000);
294
295 return () => {
305 if (language !== "en") {
306 try {
307 const translatedMessage = await fetch("/translate-text", {
308 method: "POST",
309 headers: { "Content-Type": "application/json" },
331 if (inputMessage && roomId && username) {
332 try {
333 const response = await fetch("/send-message", {
334 method: "POST",
335 headers: { "Content-Type": "application/json" },
362 } else {
363 try {
364 const response = await fetch("/update-user", {
365 method: "POST",
366 headers: { "Content-Type": "application/json" },
419 if (roomId && username) {
420 try {
421 await fetch("/update-typing", {
422 method: "POST",
423 headers: { "Content-Type": "application/json" },

GithubPRFetcher

@andybak•Updated 2 days ago

proxiedfetch1 file match

@jayden•Updated 2 days ago