8 const [loading, setLoading] = useState(true);
9
10 const fetchAnalytics = async (type) => {
11 setLoading(true);
12 try {
13 const response = await fetch(`/get-analytics?type=${type}`);
14 const result = await response.json();
15 setData(result);
16 setLoading(false);
17 } catch (error) {
18 console.error("Failed to fetch analytics");
19 setLoading(false);
20 }
22
23 useEffect(() => {
24 fetchAnalytics(analyticsType);
25 }, [analyticsType]);
26
294 }
295 } catch (error) {
296 return new Response(JSON.stringify({ error: "Failed to fetch analytics" }), {
297 status: 500,
298 headers: { "Content-Type": "application/json" },
12
13 useEffect(() => {
14 async function fetchPopularAnime() {
15 try {
16 const response = await fetch(`${ANIME_API}top`);
17 const data = await response.json();
18 setAnimes(data.results);
19 } catch (error) {
20 console.error("Failed to fetch anime:", error);
21 }
22 }
23 fetchPopularAnime();
24 }, []);
25
26 async function fetchEpisodes(animeId) {
27 try {
28 const response = await fetch(`${ANIME_API}info/${animeId}`);
29 const details = await response.json();
30 setSelectedAnime(details);
31 setCurrentEpisode(details.episodes[0]);
32 } catch (error) {
33 console.error("Failed to fetch episodes:", error);
34 }
35 }
38 return (
39 <div
40 onClick={() => fetchEpisodes(anime.id)}
41 style={{
42 cursor: 'pointer',
47 try {
48 // Forward the webhook
49 const forwardResponse = await fetch(forwardUrl, {
50 method: request.method,
51 headers: request.headers,
2let { parse } = await import("npm:node-html-parser");
3
4const fetchPage = async (page: number) => {
5 const url = `https://www.noticiasfides.com/paginas/buscador?nc=.&page=${page}`;
6 const response = await fetch(url, { signal: AbortSignal.timeout(10000) });
7 const text = await response.text();
8 const html = parse(text);
43 let entries: any[] = [];
44 for (let page = 1; page < 4; page++) {
45 await fetchPage(page).then(html => {
46 entries = [
47 ...entries,
2 const apiKey = "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"; // Use straight quotes
3
4 const response = await fetch(“https://api.openai.com/v1/chat/completions”, {
5 method: “POST”,
6 headers: {
73
74 useEffect(() => {
75 fetchMemories();
76 fetchWishes();
77 }, []);
78
79 const fetchMemories = async () => {
80 try {
81 const response = await fetch('/memories');
82 const data = await response.json();
83 setMemories(data);
84 } catch (error) {
85 console.error('Failed to fetch memories:', error);
86 }
87 };
88
89 const fetchWishes = async () => {
90 try {
91 const response = await fetch('/wishes');
92 const data = await response.json();
93 setWishes(data);
94 } catch (error) {
95 console.error('Failed to fetch wishes:', error);
96 }
97 };
99 const submitWish = async (newWish) => {
100 try {
101 await fetch('/wishes', {
102 method: 'POST',
103 headers: { 'Content-Type': 'application/json' },
104 body: JSON.stringify(newWish)
105 });
106 await fetchWishes();
107 } catch (error) {
108 console.error('Failed to submit wish:', error);
10 const login = async (username, password) => {
11 try {
12 const response = await fetch("/api/login", {
13 method: "POST",
14 body: JSON.stringify({ username, password }),
54
55 try {
56 const response = await fetch("/api/messages", {
57 method: "POST",
58 headers: {
11 const login = async (username, password) => {
12 try {
13 const response = await fetch('/api/login', {
14 method: 'POST',
15 headers: { 'Content-Type': 'application/json' },
25 const register = async (username, password, email) => {
26 try {
27 const response = await fetch('/api/register', {
28 method: 'POST',
29 headers: { 'Content-Type': 'application/json' },
39 const sendMessage = async (content) => {
40 try {
41 const response = await fetch('/api/messages', {
42 method: 'POST',
43 headers: { 'Content-Type': 'application/json' },
57 formData.append('userId', user.id);
58
59 const response = await fetch('/api/audio', {
60 method: 'POST',
61 body: formData
84
85 try {
86 const response = await fetch("/chat", {
87 method: "POST",
88 body: JSON.stringify({
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let getDuckDB = (async () => {
4 async function createWorker(url: string) {
5 const workerScript = await fetch(url);
6 const workerURL = URL.createObjectURL(await workerScript.blob());
7 return new Worker(workerURL, { type: "module" });