12 setIsLoading(true);
13 try {
14 const response = await fetch("https://esm.town/v/stevekrouse/openai", {
15 method: "POST",
16 headers: { "Content-Type": "application/json" },
44
45 useEffect(() => {
46 fetchLeaderboard();
47 }, []);
48
49 const fetchLeaderboard = async () => {
50 const response = await fetch("?action=leaderboard");
51 const data = await response.json();
52 setLeaderboard(data);
66 }
67
68 await fetch("?action=update", {
69 method: "POST",
70 body: JSON.stringify({ name: playerName, xp: newXp, level: newLevel }),
71 });
72
73 fetchLeaderboard();
74 };
75
121 "https://api.val.town/v1/run/rodrigotello.updateDinoScoreboard";
122
123 fetch(apiUrl, {
124 method: "POST",
125 headers: {
139 .then((result) => {
140 console.log("Scoreboard updated:", result);
141 // Update the scoreboard variable with the fetched data
142 scoreboard = result;
143 })
157 text("Press SPACE to play again", width / 2, height / 2 + 10);
158
159 // Fetch the latest scoreboard data
160 const apiUrl =
161 "https://api.val.town/v1/run/rodrigotello.dinoGameScoreboard";
8
9 useEffect(() => {
10 fetchItems();
11 }, []);
12
13 const fetchItems = async () => {
14 const response = await fetch("/items");
15 const data = await response.json();
16 setItems(data);
19 const handleAddItem = async () => {
20 if (newItem.trim() === "") return;
21 await fetch("/items", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },
25 });
26 setNewItem("");
27 fetchItems();
28 };
29
35
36 const removeItem = async (id) => {
37 await fetch(`/items/${id}`, { method: "DELETE" });
38 fetchItems();
39 };
40
41 const clearList = async () => {
42 await fetch("/items", { method: "DELETE" });
43 fetchItems();
44 };
45
16
17 useEffect(() => {
18 fetchCSV();
19 }, []);
20
25 }, [flashcards]);
26
27 const fetchCSV = async () => {
28 const response = await fetch("/csv");
29 const csvText = await response.text();
30 const result = Papa.parse(csvText, { header: false });
57 const formData = new FormData();
58 formData.append("csv", file);
59 const response = await fetch("/upload", {
60 method: "POST",
61 body: formData,
63 if (response.ok) {
64 alert("File uploaded successfully!");
65 fetchCSV();
66 } else {
67 alert("Error uploading file.");
1import { email } from "https://esm.town/v/std/email";
2
3async function fetchTweets(listId: string): Promise<any[]> {
4 const url = `https://news.ycombinator.com/`;
5 const response = await fetch(url);
6 const html = await response.text();
7 console.log(html);
27export default async function(interval: Interval) {
28 const listId = "1359390628841480192";
29 const tweets = await fetchTweets(listId);
30
31 // Sort tweets by likes and get top 10
11 const generateText = async () => {
12 setLoading(true);
13 const response = await fetch(`?paragraphs=${paragraphs}`);
14 const result = await response.text();
15 setText(result);
30 setLoading(prev => ({ ...prev, [operation]: true }));
31 try {
32 const response = await fetch(`/run?operation=${operation}`, {
33 method: "POST",
34 headers: {
138}
139
140async function fetchContent(): Promise<string> {
141 const response = await fetch("https://www.gutenberg.org/cache/epub/1342/pg1342.txt");
142 const text = await response.text();
143
151 const MODEL_NAME = "claude-3-5-sonnet-20240620";
152
153 const bookContent = await fetchContent();
154 const startTime = Date.now();
155
187 const MODEL_NAME = "claude-3-5-sonnet-20240620";
188
189 const bookContent = await fetchContent();
190 const startTime = Date.now();
191
226 const MODEL_NAME = "claude-3-5-sonnet-20240620";
227
228 const bookContent = await fetchContent();
229 const questions = [
230 "What is the title of this novel?",
4
5 try {
6 const response = await fetch(url);
7
8 if (!response.ok) {
13 const firstImageUrl = "https://cn.bing.com" + data.images[0].url;
14 // 第三æ¥ï¼šè¯·æ±‚该图片的实际内容
15 const imageResponse = await fetch(firstImageUrl);
16
17 if (!imageResponse.ok) {
18 throw new Error(`Failed to fetch image! status: ${imageResponse.status}`);
19 }
20
26 });
27 } catch (error) {
28 console.error("Error fetching data:", error);
29 return new Response(JSON.stringify({ error: "Failed to fetch data" }), {
30 status: 500,
31 headers: {
94 tokenUrl.searchParams.set("state", store.state);
95
96 const tokenResp = await fetch(tokenUrl.toString());
97 if (!tokenResp.ok) {
98 throw new Error(await tokenResp.text());
103 };
104
105 const resp = await fetch("https://lastlogin.io/userinfo", {
106 headers: {
107 Authorization: `Bearer ${access_token}`,