51 setTrainingPlan("");
52 setYoutubeLinks([]);
53 const response = await fetch("/generate-training", {
54 method: "POST",
55 headers: { "Content-Type": "application/json", "Regenerate-Key": regenerateKey.toString() },
76 setSharing(true);
77 try {
78 const response = await fetch("/share-training", {
79 method: "POST",
80 headers: { "Content-Type": "application/json" },
801 const videoPlaceholders = trainingPlan.match(/\[VIDEO: .+?\]/g) || [];
802
803 // Fetch and embed YouTube videos
804 const youtubeLinks = [];
805 for (const placeholder of videoPlaceholders) {
897 encodeURIComponent(sport + " " + query)
898 }&key=${apiKey}&type=video&maxResults=1`;
899 const response = await fetch(searchUrl);
900 const data = await response.json();
901 if (data.error) {
907 }
908 } catch (error) {
909 console.error("Error fetching from YouTube API:", error);
910 }
911 }
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6
315 <html>
316 <body>
317 <h1>Error Fetching Weather</h1>
318 <p>${error.message}</p>
319 </body>
9 return metadata;
10 } catch (err) {
11 console.error("Error fetching metadata:", err);
12 return null;
13 }
75);
76
77export default app.fetch;
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4// Fetches a random joke.
5async function fetchRandomJoke() {
6 const response = await fetch(
7 "https://official-joke-api.appspot.com/random_joke",
8 );
10}
11
12const randomJoke = await fetchRandomJoke();
13const setup = randomJoke.setup;
14const punchline = randomJoke.punchline;
11 const runTests = async () => {
12 try {
13 const response = await fetch("/run-tests", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },
113 const runTests = async () => {
114 try {
115 const response = await fetch("/run-tests", {
116 method: "POST",
117 headers: { "Content-Type": "application/json" },
234 } catch (error) {
235 console.error("Error in runTests:", error);
236 if (error instanceof TypeError && error.message.includes("Failed to fetch dynamically imported module")) {
237 return {
238 success: false,
9 async function request(url, options) {
10 try {
11 const response = await fetch(url, options);
12 const status = response.status;
13 const data = await response.text();
10 const postToBluesky = async () => {
11 try {
12 const response = await fetch("/post-bluesky", {
13 method: "POST",
14 headers: {
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
10}
11
12const randomJoke = fetchRandomJoke();
13const setup = randomJoke.setup;
14const punchline = randomJoke.punchline;
70 setError("");
71 try {
72 const response = await fetch("/generate", {
73 method: "POST",
74 headers: { "Content-Type": "application/json" },
197 onClick={async () => {
198 try {
199 const response = await fetch(`/update/${noteId}`, {
200 method: "POST",
201 headers: { "Content-Type": "application/json" },