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/$%7Burl%7D?q=fetch&page=94&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 14114 results for "fetch"(5070ms)

sendMessagetelegram_sender.ts1 match

@charmaine•Updated 1 week ago
96
97 // Send message to Telegram
98 const telegramResponse = await fetch(telegramUrl, {
99 method: 'POST',
100 headers: {

MinnehahaCreekFlowmain.tsx2 matches

@greg_dryke•Updated 1 week ago
4 const SITE_ID = "05289800";
5
6 // Fetch data from USGS API
7 const response = await fetch(
8 `https://waterservices.usgs.gov/nwis/iv/?format=json&sites=${SITE_ID}&parameterCd=00060`,
9 );

val-town-pagesmain.tsx1 match

@pomdtr•Updated 1 week ago
17});
18
19export default app.fetch;

osaccounts-schema.ts1 match

@dinavinter•Updated 1 week ago
22 });
23
24 const response = await fetch(url, {
25 method: "POST",
26 headers: { "Content-Type": "application/x-www-form-urlencoded" },

linkInBioTemplatemain.tsx14 matches

@imandel•Updated 1 week ago
4
5 try {
6 // Fetch the user's main page with retry logic
7 const userPageUrl = `https://soundgasm.net/u/${username}`;
8 const userPageHtml = await fetchWithRetry(userPageUrl);
9
10 if (!userPageHtml) {
11 throw new Error(`Unable to fetch user page for ${username}`);
12 }
13
19 }
20
21 // Fetch audio URLs for each episode with controlled concurrency
22 const episodesWithAudio = await fetchEpisodesWithConcurrencyLimit(
23 episodes.slice(0, 20),
24 3, // Limit concurrent requests to avoid overwhelming the server
49}
50
51async function fetchWithRetry(url: string, maxRetries = 3, delayMs = 1000): Promise<string | null> {
52 const headers = {
53 "User-Agent":
62 for (let attempt = 1; attempt <= maxRetries; attempt++) {
63 try {
64 console.log(`Fetching ${url} (attempt ${attempt}/${maxRetries})`);
65
66 const controller = new AbortController();
67 const timeoutId = setTimeout(() => controller.abort(), 15000); // 15 second timeout
68
69 const response = await fetch(url, {
70 headers,
71 signal: controller.signal,
79
80 const text = await response.text();
81 console.log(`Successfully fetched ${url} (${text.length} characters)`);
82 return text;
83 } catch (error) {
98}
99
100async function fetchEpisodesWithConcurrencyLimit(episodes: any[], limit: number): Promise<any[]> {
101 const results = [];
102
108 batch.map(async (episode) => {
109 try {
110 console.log(`Fetching episode: ${episode.title}`);
111 const episodeHtml = await fetchWithRetry(episode.url, 2, 500); // Fewer retries for individual episodes
112
113 if (!episodeHtml) {
114 console.warn(`Failed to fetch episode: ${episode.title}`);
115 return { ...episode, audioUrl: null, error: "Failed to fetch episode page" };
116 }
117

sendMessagesendMessage.ts6 matches

@charmaine•Updated 1 week ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Platform-specific types
62 }
63
64 const res = await fetch(webhookUrl, {
65 method: "POST",
66 redirect: "follow",
85 // Use webhook if available (simpler)
86 if (webhookUrl) {
87 const res = await fetch(webhookUrl, {
88 method: "POST",
89 body: JSON.stringify(body),
99 };
100
101 const response = await fetch("https://slack.com/api/chat.postMessage", {
102 method: "POST",
103 headers: {
143
144 try {
145 const response = await fetch("https://onesignal.com/api/v1/notifications", {
146 method: "POST",
147 headers: {
178
179 try {
180 const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`, {
181 method: "POST",
182 headers: {

valboardemail.tsx1 match

@avycado13•Updated 1 week ago
17
18 // Send the POST request to the API endpoint
19 fetch(url, {
20 method: "POST",
21 headers: {

subcurrentShuffle2App.tsx6 matches

@ashryanio•Updated 1 week ago
28 const [error, setError] = useState<string | null>(null);
29
30 const fetchRandomPost = async () => {
31 setLoading(true);
32 setError(null);
33
34 try {
35 const response = await fetch("/api/random-post");
36
37 if (!response.ok) {
38 const errorData = await response.json();
39 throw new Error(errorData.error || "Failed to fetch post");
40 }
41
51
52 useEffect(() => {
53 fetchRandomPost();
54 }, []);
55
103 <div className="text-center mb-8">
104 <button
105 onClick={fetchRandomPost}
106 disabled={loading}
107 className="bg-indigo-600 hover:bg-indigo-700 disabled:bg-indigo-400 text-white font-semibold py-3 px-6 rounded-lg shadow-lg transition-colors duration-200 inline-flex items-center gap-2"
180 <div className="bg-white rounded-xl shadow-lg p-8 text-center">
181 <div className="animate-spin rounded-full h-12 w-12 border-4 border-indigo-200 border-t-indigo-600 mx-auto mb-4"></div>
182 <p className="text-gray-600">Fetching a random post...</p>
183 </div>
184 )}

subcurrentShuffle3README.md3 matches

@ashryanio•Updated 1 week ago
1# Random Subcurrent Post
2
3A Val Town application that fetches a random post from the [Subcurrent](https://astoria-tech.github.io/subcurrent-astro/) RSS feed and displays it in a clean, responsive web interface.
4
5## Features
6
7- 🎲 **Random Post Selection**: Fetches a random article from the Subcurrent RSS feed
8- 📱 **Responsive Design**: Clean, mobile-friendly interface using TailwindCSS
9- 🔄 **Refresh Functionality**: Get a new random post with the click of a button
41## Usage
42
43Visit the deployed Val to see a random Subcurrent post. Click the "Get Another Random Post" button to fetch a new random article.
44
45The application automatically handles RSS feed discovery and parsing, making it easy to adapt for other RSS-enabled websites.

subcurrentShuffle3index.ts9 matches

@ashryanio•Updated 1 week ago
67 try {
68 // First, let's try to find the RSS feed URL
69 const siteResponse = await fetch("https://astoria-tech.github.io/subcurrent-astro/");
70 if (!siteResponse.ok) {
71 return c.json({ error: `Failed to fetch site: ${siteResponse.status}` }, 500);
72 }
73
94 const testUrl = "https://astoria-tech.github.io/subcurrent-astro" + path;
95 try {
96 const testResponse = await fetch(testUrl);
97 if (testResponse.ok) {
98 const testContent = await testResponse.text();
121 }
122
123 // Fetch the RSS feed
124 const rssResponse = await fetch(rssUrl);
125 if (!rssResponse.ok) {
126 return c.json({
127 error: `Failed to fetch RSS feed: ${rssResponse.status}`,
128 rssUrl: rssUrl
129 }, 500);
153
154 } catch (error) {
155 console.error("Error fetching RSS:", error);
156 return c.json({
157 error: "Failed to fetch RSS feed",
158 details: error.message
159 }, 500);
172});
173
174export default app.fetch;

FetchBasic2 file matches

@ther•Updated 1 week ago

GithubPRFetcher

@andybak•Updated 1 week ago