2526useEffect(() => {
27fetchComments();
28fetchRating();
29}, []);
3031const fetchComments = async () => {
32const response = await fetch(`/${type}/${item.id}/comments`);
33if (response.ok) {
34const data = await response.json();
37};
3839const fetchRating = async () => {
40const response = await fetch(`/${type}/${item.id}/rating`);
41if (response.ok) {
42const data = await response.json();
4647const addComment = async () => {
48const response = await fetch(`/${type}/${item.id}/comments`, {
49method: 'POST',
50headers: { 'Content-Type': 'application/json' },
53if (response.ok) {
54setNewComment('');
55fetchComments();
56}
57};
5859const addRating = async (newRating) => {
60const response = await fetch(`/${type}/${item.id}/rating`, {
61method: 'POST',
62headers: { 'Content-Type': 'application/json' },
108109useEffect(() => {
110fetchInitialData();
111fetchFavorites();
112}, [page]);
113114const fetchInitialData = async () => {
115const response = await fetch(`/search?type=${page}&query=`);
116if (response.ok) {
117const data = await response.json();
123};
124125const fetchFavorites = async () => {
126const response = await fetch("/favorites");
127if (response.ok) {
128const data = await response.json();
133const handleSearch = async (e) => {
134if (e.key === "Enter" || e.type === "click") {
135const response = await fetch(`/search?type=${page}&query=${encodeURIComponent(search)}`);
136if (response.ok) {
137const data = await response.json();
146const toggleFavorite = async (item, type) => {
147const method = favorites[type].some(fav => fav.id === item.id) ? 'DELETE' : 'POST';
148const response = await fetch(`/favorites/${type}`, {
149method,
150headers: { 'Content-Type': 'application/json' },
152});
153if (response.ok) {
154fetchFavorites();
155}
156};
157158const addLostPet = async (petData) => {
159const response = await fetch("/lostPets", {
160method: "POST",
161headers: { 'Content-Type': 'application/json' },
163});
164if (response.ok) {
165fetchInitialData();
166}
167};
11setLoading(true);
12try {
13const response = await fetch("/create-checkout-session", {
14method: "POST",
15headers: {
passwordGenmain.tsx1 match
222}
223224const response = await fetch("/generate", {
225method: "POST",
226headers: { "Content-Type": "application/json" },
sendNtifyNotificationmain.tsx2 matches
1import { fetch } from 'https://esm.town/v/std/fetch';
23export type NtfyPayload = {
2223const body = JSON.stringify({ ...payload, topic });
24const res = await fetch(server, {
25method: 'POST',
26headers: {
fullPageWebsiteScrapermain.tsx14 matches
55}
56}
57// Link Fetching Helper
58export class LinkFetcher {
59static discoveredUrls = new Set();
60static pageDepths = new Map();
61static processQueue = [];
6263static async fetchLinksFromWebsite(websiteUrl) {
64console.log(`\nFetching links from website: ${websiteUrl}`);
65console.log("Initial HTML structure analysis begin");
66const query = `
7980console.log(`Making LSD API request for ${websiteUrl}`);
81const response = await fetch(
82`https://lsd.so/api?query=${encodeURIComponent(query)}`,
83);
8485if (!response.ok) {
86console.log(`Failed to fetch links from ${websiteUrl}`);
87return [];
88}
148const currentBatch = pagesToProcess.splice(0, 10);
149const batchPromises = currentBatch.map(async (pageUrl) => {
150console.log(`Fetching links from: ${pageUrl}`);
151const pageQuery = `
152SELECT
162163console.log(`Making LSD API request for ${pageUrl}`);
164const response = await fetch(
165`https://lsd.so/api?query=${encodeURIComponent(pageQuery)}`,
166);
167168if (!response.ok) {
169console.log(`Failed to fetch links from ${pageUrl}`);
170return [];
171}
235}
236237console.log(`Successfully fetched ${allLinks.length} links from ${discoveredPages.size} pages`);
238return allLinks;
239}
279try {
280console.log(`Attempting HEAD request for: ${url}`);
281const response = await fetch(url, { method: "HEAD" });
282283if (!response.ok) {
284console.log(`HEAD request failed, attempting GET request for: ${url}`);
285const getResponse = await fetch(url, { method: "GET" });
286return { ok: getResponse.ok, status: getResponse.status };
287}
431};
432433// Fetch all links with progress tracking
434const links = await LinkFetcher.fetchLinksFromWebsite(websiteUrl);
435const totalPages = new Set(links.map(link =>
436new URL(link.link, websiteUrl).origin + new URL(link.link, websiteUrl).pathname
sqliteExplorerAppmain.tsx4 matches
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
xmasRedHamstermain.tsx1 match
28async function getMostPopularPinterestImage(query: string): Promise<string> {
29const searchUrl = `https://api.pinterest.com/v5/search/pins?query=${encodeURIComponent(query)}&page_size=50&sort_order=popularity`;
30const response = await fetch(searchUrl, {
31headers: {
32"Accept-Language": "en-US",
xmasRedHamstermain.tsx1 match
28async function getMostPopularPinterestImage(query: string): Promise<string> {
29const searchUrl = `https://api.pinterest.com/v5/search/pins?query=${encodeURIComponent(query)}&page_size=50&sort_order=popularity`;
30const response = await fetch(searchUrl, {
31headers: {
32"Accept-Language": "en-US",
tokencountermain.tsx1 match
34if (modelFamily === "Anthropic" && anthropicApiKey) {
35try {
36const response = await fetch("/api/count-tokens", {
37method: "POST",
38headers: {
multilingualchatroommain.tsx21 matches
211useEffect(() => {
212if (roomId) {
213const fetchDefaultUsername = async () => {
214try {
215// First, check if there's a username in localStorage
218setUsername(storedUsername);
219} else {
220// If not, fetch a default username from the server
221const response = await fetch(`/default-username?room=${roomId}`);
222if (response.ok) {
223const defaultUsername = await response.text();
234}
235} catch (error) {
236console.error("Error fetching default username:", error);
237}
238};
239240fetchDefaultUsername();
241}
242}, [roomId]);
246const pollMessages = async () => {
247try {
248const response = await fetch(`/messages?room=${roomId}&language=${language}`);
249if (response.ok) {
250const newMessages = await response.json();
258}
259} catch (error) {
260console.error("Error fetching messages:", error);
261}
262};
263264const fetchUsers = async () => {
265try {
266const response = await fetch(`/users?room=${roomId}`);
267if (response.ok) {
268const userList = await response.json();
270}
271} catch (error) {
272console.error("Error fetching users:", error);
273}
274};
275276const fetchTypingUsers = async () => {
277try {
278const response = await fetch(`/typing-users?room=${roomId}`);
279if (response.ok) {
280const typingUsersList = await response.json();
282}
283} catch (error) {
284console.error("Error fetching typing users:", error);
285}
286};
287288pollMessages();
289fetchUsers();
290fetchTypingUsers();
291const messageIntervalId = setInterval(pollMessages, 2000);
292const userIntervalId = setInterval(fetchUsers, 5000);
293const typingIntervalId = setInterval(fetchTypingUsers, 1000);
294295return () => {
305if (language !== "en") {
306try {
307const translatedMessage = await fetch("/translate-text", {
308method: "POST",
309headers: { "Content-Type": "application/json" },
331if (inputMessage && roomId && username) {
332try {
333const response = await fetch("/send-message", {
334method: "POST",
335headers: { "Content-Type": "application/json" },
362} else {
363try {
364const response = await fetch("/update-user", {
365method: "POST",
366headers: { "Content-Type": "application/json" },
419if (roomId && username) {
420try {
421await fetch("/update-typing", {
422method: "POST",
423headers: { "Content-Type": "application/json" },