9697// Send message to Telegram
98const telegramResponse = await fetch(telegramUrl, {
99method: 'POST',
100headers: {
MinnehahaCreekFlowmain.tsx2 matches
4const SITE_ID = "05289800";
5
6// Fetch data from USGS API
7const response = await fetch(
8`https://waterservices.usgs.gov/nwis/iv/?format=json&sites=${SITE_ID}¶meterCd=00060`,
9);
val-town-pagesmain.tsx1 match
17});
1819export default app.fetch;
osaccounts-schema.ts1 match
22});
2324const response = await fetch(url, {
25method: "POST",
26headers: { "Content-Type": "application/x-www-form-urlencoded" },
linkInBioTemplatemain.tsx14 matches
45try {
6// Fetch the user's main page with retry logic
7const userPageUrl = `https://soundgasm.net/u/${username}`;
8const userPageHtml = await fetchWithRetry(userPageUrl);
910if (!userPageHtml) {
11throw new Error(`Unable to fetch user page for ${username}`);
12}
1319}
2021// Fetch audio URLs for each episode with controlled concurrency
22const episodesWithAudio = await fetchEpisodesWithConcurrencyLimit(
23episodes.slice(0, 20),
243, // Limit concurrent requests to avoid overwhelming the server
49}
5051async function fetchWithRetry(url: string, maxRetries = 3, delayMs = 1000): Promise<string | null> {
52const headers = {
53"User-Agent":
62for (let attempt = 1; attempt <= maxRetries; attempt++) {
63try {
64console.log(`Fetching ${url} (attempt ${attempt}/${maxRetries})`);
6566const controller = new AbortController();
67const timeoutId = setTimeout(() => controller.abort(), 15000); // 15 second timeout
6869const response = await fetch(url, {
70headers,
71signal: controller.signal,
7980const text = await response.text();
81console.log(`Successfully fetched ${url} (${text.length} characters)`);
82return text;
83} catch (error) {
98}
99100async function fetchEpisodesWithConcurrencyLimit(episodes: any[], limit: number): Promise<any[]> {
101const results = [];
102108batch.map(async (episode) => {
109try {
110console.log(`Fetching episode: ${episode.title}`);
111const episodeHtml = await fetchWithRetry(episode.url, 2, 500); // Fewer retries for individual episodes
112113if (!episodeHtml) {
114console.warn(`Failed to fetch episode: ${episode.title}`);
115return { ...episode, audioUrl: null, error: "Failed to fetch episode page" };
116}
117
sendMessagesendMessage.ts6 matches
1import { fetch } from "https://esm.town/v/std/fetch";
23// Platform-specific types
62}
6364const res = await fetch(webhookUrl, {
65method: "POST",
66redirect: "follow",
85// Use webhook if available (simpler)
86if (webhookUrl) {
87const res = await fetch(webhookUrl, {
88method: "POST",
89body: JSON.stringify(body),
99};
100101const response = await fetch("https://slack.com/api/chat.postMessage", {
102method: "POST",
103headers: {
143144try {
145const response = await fetch("https://onesignal.com/api/v1/notifications", {
146method: "POST",
147headers: {
178179try {
180const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json`, {
181method: "POST",
182headers: {
1718// Send the POST request to the API endpoint
19fetch(url, {
20method: "POST",
21headers: {
subcurrentShuffle2App.tsx6 matches
28const [error, setError] = useState<string | null>(null);
2930const fetchRandomPost = async () => {
31setLoading(true);
32setError(null);
33
34try {
35const response = await fetch("/api/random-post");
36
37if (!response.ok) {
38const errorData = await response.json();
39throw new Error(errorData.error || "Failed to fetch post");
40}
41
5152useEffect(() => {
53fetchRandomPost();
54}, []);
55103<div className="text-center mb-8">
104<button
105onClick={fetchRandomPost}
106disabled={loading}
107className="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
1# Random Subcurrent Post
23A 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.
45## Features
67- 🎲 **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
4243Visit the deployed Val to see a random Subcurrent post. Click the "Get Another Random Post" button to fetch a new random article.
4445The application automatically handles RSS feed discovery and parsing, making it easy to adapt for other RSS-enabled websites.
subcurrentShuffle3index.ts9 matches
67try {
68// First, let's try to find the RSS feed URL
69const siteResponse = await fetch("https://astoria-tech.github.io/subcurrent-astro/");
70if (!siteResponse.ok) {
71return c.json({ error: `Failed to fetch site: ${siteResponse.status}` }, 500);
72}
73
94const testUrl = "https://astoria-tech.github.io/subcurrent-astro" + path;
95try {
96const testResponse = await fetch(testUrl);
97if (testResponse.ok) {
98const testContent = await testResponse.text();
121}
122
123// Fetch the RSS feed
124const rssResponse = await fetch(rssUrl);
125if (!rssResponse.ok) {
126return c.json({
127error: `Failed to fetch RSS feed: ${rssResponse.status}`,
128rssUrl: rssUrl
129}, 500);
153
154} catch (error) {
155console.error("Error fetching RSS:", error);
156return c.json({
157error: "Failed to fetch RSS feed",
158details: error.message
159}, 500);
172});
173174export default app.fetch;