spotifyPlaylistSearchmain.tsx2 matches
10const searchPlaylists = async () => {
11try {
12const response = await fetch(`/search?q=${encodeURIComponent(query)}`);
13if (!response.ok) {
14throw new Error(`HTTP error! status: ${response.status}`);
121const url = `https://itunes.apple.com/search?term=${encodeURIComponent(query)}&entity=playlist&limit=20`;
122123const response = await fetch(url);
124125if (!response.ok) {
effortlessCrimsonDolphinmain.tsx2 matches
1import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
34const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity";
9const since = lastRunAt ? Math.floor(lastRunAt.getTime() / 1000) : 0;
10url.searchParams.append("query", query + " since_time:" + since);
11const { tweets } = await fetchJSON(url.toString(), {
12bearer: Deno.env.get("SOCIAL_DATA_API_KEY"),
13});
multiUserChatwithLLMmain.tsx12 matches
1213useEffect(() => {
14fetchMessages();
15getOrCreateUsername();
16const intervalId = setInterval(() => {
17fetchNewMessages();
18checkReset();
19}, 1000); // Poll every second
32let storedUsername = localStorage.getItem("chatUsername");
33if (!storedUsername) {
34const response = await fetch("/username");
35const data = await response.json();
36storedUsername = data.username;
40};
4142const fetchMessages = async () => {
43const response = await fetch("/messages");
44const data = await response.json();
45setMessages(data);
49};
5051const fetchNewMessages = async () => {
52const response = await fetch(`/new-messages?lastId=${lastMessageIdRef.current}`);
53const newMessages = await response.json();
54if (newMessages.length > 0) {
5960const checkReset = async () => {
61const response = await fetch(`/check-reset?token=${resetTokenRef.current}`);
62const data = await response.json();
63if (data.reset) {
74setInput("");
7576const response = await fetch("/send", {
77method: "POST",
78headers: { "Content-Type": "application/json" },
8182if (response.ok) {
83fetchNewMessages(); // Immediately fetch new messages after sending
84}
85};
8687const resetChat = async () => {
88const response = await fetch("/reset", { method: "POST" });
89if (response.ok) {
90setMessages([]);
164await sqlite.execute(`INSERT INTO ${KEY}_messages_${SCHEMA_VERSION} (role, content, username) VALUES (?, ?, ?)`, ["user", message, username]);
165
166// Fetch recent context
167const contextResult = await sqlite.execute(
168`SELECT role, content, username FROM ${KEY}_messages_${SCHEMA_VERSION}
1Migrated from folder: fanficSearcher/ScrapingBeeAttempt/ThreadmarkLISTFetcher2
ThreadmarkLISTFetchermain.tsx16 matches
11loading = true;
12updateUI();
13console.log(`Fetching threadmarks for URL: ${url}`);
14try {
15result = await fetchThreadmarksFromServer(url, chapterTitles);
16} catch (error) {
17console.log(`Error occurred while fetching threadmarks: ${error.message}`);
18result = { error: error.message };
19}
26root.innerHTML = `
27<div>
28<h1>Threadmark Fetcher and Comparator</h1>
29<form id="threadmarkForm">
30<div>
33id="urlInput"
34value="${url}"
35placeholder="Enter URL to fetch threadmarks"
36required
37/>
46</div>
47<button type="submit" ${loading ? "disabled" : ""}>
48${loading ? "Fetching..." : "Fetch and Compare Threadmarks"}
49</button>
50</form>
139}
140141async function fetchThreadmarksFromServer(url, chapterTitles) {
142const response = await fetch("/api/threadmarks", {
143method: "POST",
144headers: {
156async function getThreadmarkUrls(baseUrl, apiKey) {
157versionLogger(import.meta.url);
158console.log(`[START] Threadmark URL fetch for base URL: ${baseUrl}`);
159const startTime = Date.now();
160173174const requestStartTime = Date.now();
175const response = await fetch(scrapingBeeUrl);
176console.log(
177`Response received. Status: ${response.status}, Headers: ${
246allThreadmarks = allThreadmarks.concat(threadmarks);
247} catch (error) {
248console.error(`[ERROR] Exception during fetching or parsing for category ${category}:`);
249console.error(`[ERROR] Error name: ${error.name}`);
250console.error(`[ERROR] Error message: ${error.message}`);
256const totalDuration = Date.now() - startTime;
257console.log(
258`[END] Finished fetching threadmarks for all categories in ${totalDuration} ms. Total threadmarks found: ${allThreadmarks.length}`,
259);
260349try {
350const { url, chapterTitles } = await request.json();
351console.log(`[INFO] Received request to fetch threadmarks for URL: ${url}`);
352const threadmarks = await getThreadmarkUrls(url, apiKey);
353console.log(`[INFO] Retrieved ${threadmarks.length} threadmarks`);
368}
369} catch (error) {
370console.error("[ERROR] Error in threadmark fetching or comparison:");
371console.error(`[ERROR] Error name: ${error.name}`);
372console.error(`[ERROR] Error message: ${error.message}`);
374return new Response(
375JSON.stringify({
376error: `Error fetching threadmarks: ${error.message}`,
377stack: error.stack,
378}),
393<meta charset="UTF-8">
394<meta name="viewport" content="width=device-width, initial-scale=1.0">
395<title>Threadmark Fetcher and Comparator</title>
396<style>${CSS}</style>
397</head>
currencyTransactionmain.tsx4 matches
1import { fetch } from "https://esm.town/v/std/fetch";
23async function fetchJSON(url: string) {
4const response = await fetch(url);
5if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
6return response.json();
21// View at https://wallek-currencyTransaction.val.run?target=gbp&root=eur&amount=100
22export default async function(req: Request): Promise<Response> {
23const { rates } = await fetchJSON(`https://api.exchangerate-api.com/v4/latest/USD`);
2425// USD is the base currency, so we need to add it manually
getAirtableDataAPImain.tsx4 matches
4const tableName = Deno.env.get("AIRTABLE_TABLE_NAME");
56async function fetchAirtableData(uid: string) {
7if (!airtableApiKey || !baseId || !tableName) {
8throw new Error("Missing Airtable environment variables");
1011const url = `https://api.airtable.com/v0/${baseId}/${tableName}?filterByFormula=UID%3D%22${encodeURIComponent(uid)}%22`;
12const response = await fetch(url, {
13headers: {
14Authorization: `Bearer ${airtableApiKey}`,
53}
5455const record = await fetchAirtableData(uid);
5657if (!record) {
73return Response.json({ data }, { headers });
74} catch (error) {
75console.error("Error fetching Airtable data:", error);
76return new Response("Internal Server Error", { status: 500 });
77}
HTMX_templatemain.tsx2 matches
5354var formBody = "userGroup=&email=" + encodeURIComponent(formInput.value);
55fetch(event.target.action, {
56method: "POST",
57body: formBody,
80.catch(error => {
81// check for cloudflare error
82if (error.message === "Failed to fetch") {
83rateLimit();
84return;
wordcountermain.tsx1 match
169app.get("/", (c) => c.html(html));
170171export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
146try {
147const url = '${url}';
148const response = await fetch(url, {
149method: 'POST',
150headers: {
156if (!response.ok) {
157let errorJson = await response.json();
158console.error('Fetch Error:', errorJson);
159showError('Error fetching data: ' + (errorJson.message || 'Unknown error'));
160return;
161}
359app.get("/", (c) => c.html(html));
360361export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;