hallwayEmbedPokemonindex.html4 matches
25
26async function main() {
27const count = await fetch("https://pokeapi.co/api/v2/pokemon")
28.then(res => res.json())
29.then(json => json.count)
30
31const fetchPokemon = async (index) => {
32const pokemon = await fetch(`https://pokeapi.co/api/v2/pokemon/${index}`)
33.then(res => res.json())
34
38btn.onclick = async () => {
39const index = randomIntFromInterval(1, 500)
40const pokemon = await fetchPokemon(index)
41
42sprite.src = pokemon.sprites.front_default
hallwayEmbedPokemonserver.ts1 match
11);
1213export default app.fetch;
helloStaticSitemain.ts2 matches
16});
1718// HTTP vals expect an exported "fetch handler"
19// This is how you "run the server" in Val Town with Hono
20export default app.fetch;
gemini-testmain.tsx1 match
7980try {
81const geminiResponse = await fetch(targetUrl, {
82method: req.method,
83headers: headersToGemini,
pinboardviewerindex.ts1 match
201<div class="bg-white p-8 rounded-lg shadow-md max-w-md">
202<h1 class="text-2xl font-bold text-red-600 mb-4">Error</h1>
203<p class="text-gray-600 mb-4">Failed to fetch data from the pins table.</p>
204<p class="text-sm text-gray-500">Error: ${escapeHtml(error.message)}</p>
205<a href="/"
untitled-2689main.tsx13 matches
604const triggerTelegramInteraction = async (chatId) => {
605try {
606const response = await fetch("/handle-telegram-interaction", {
607method: "POST",
608headers: { "Content-Type": "application/json" },
621};
622623const fetchUserBalance = async () => {
624let userId = null;
625let isTelegramEnv = false;
674if (userId) {
675try {
676const response = await fetch(`/get-balance?uid=${userId}`);
677if (!response.ok) {
678try {
699}
700} catch (error) {
701console.error("Failed to fetch or process balance:", error.toString());
702setBalance("Error");
703}
704} else {
705console.error("User ID could not be determined for balance fetching.");
706setBalance("--.--");
707}
727window.Telegram.WebApp.ready();
728}
729fetchUserBalance();
730} else if (isTelegramWebAppPresent) {
731console.log(
732"Telegram script present, but user data not immediately available or ready() pending. Setting timeout for balance fetch.",
733);
734if (window.Telegram.WebApp.ready) {
735window.Telegram.WebApp.ready();
736}
737scriptLoadTimeoutId = setTimeout(fetchUserBalance, 300);
738} else {
739console.log("Not in Telegram environment. Proceeding as web user for balance fetch.");
740fetchUserBalance();
741}
742}
878setShowSpinner(true);
879880const response = await fetch("/save-credentials", {
881method: "POST",
882headers: { "Content-Type": "application/json" },
1880const sendActualTelegramAPIMessage = async (botToken, chatId, text, parseMode = "Markdown") => {
1881try {
1882const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
1883method: "POST",
1884headers: { "Content-Type": "application/json" },
2190if (confirm('Are you sure you want to unban this user?')) {
2191try {
2192const response = await fetch('/unban-telegram-user', {
2193method: 'POST',
2194headers: { 'Content-Type': 'application/json' },
proxiedfetchmain.tsx2 matches
1import { fetch as proxiedFetch } from "https://esm.town/v/std/fetch";
23export default async function (req: Request): Promise<Response> {
2829try {
30const upstream = await proxiedFetch(target, init);
31// Stream status, statusText, headers, and body back to the client
32return new Response(upstream.body, {
264<textarea id="legal-task-query" name="legalTaskQuery" placeholder="E.g., 'Identify all clauses related to termination for cause.' or 'Summarize the key obligations of Party A.'">${escapedQuery}</textarea>
265266<label for="doc-url">Document URL (Optional - content will be fetched):</label>
267<input type="text" id="doc-url" name="documentUrl" value="${escapedUrl}" placeholder="https://example.com/legal-document.html">
268491inputSourceDescription = \`URL: \${urlValue}\`;
492formData.append('documentUrl', urlValue);
493addStatusMessage(\`Fetching and processing content from URL: \${urlValue}\`, 'progress');
494}
495formData.append('inputSourceDescription', inputSourceDescription);
498try {
499// The Val itself acts as the API endpoint
500const response = await fetch(window.location.pathname + '?format=json', {
501method: 'POST',
502// FormData sets Content-Type automatically
568const { OpenAI } = await import("https://esm.town/v/std/openai");
569const { z } = await import("npm:zod"); // For potential future robust input validation on server
570const { fetch } = await import("https://esm.town/v/std/fetch");
571const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract");
572692documentText = input.documentText;
693} else if (input.documentUrl) {
694log.push({ agent: ingestionAgent, type: "step", message: `Fetching from URL: ${input.documentUrl}` });
695try {
696// Basic fetch, consider adding User-Agent, timeout, error handling, content-type checking
697const response = await fetch(input.documentUrl, {
698headers: { "Accept": "text/plain, text/html, application/pdf" },
699}); // Accept PDF too
702const contentType = response.headers.get("content-type") || "";
703if (contentType.includes("application/pdf")) {
704log.push({ agent: ingestionAgent, type: "info", message: "Fetched PDF from URL. Extracting text..." });
705const pdfBuffer = await response.arrayBuffer();
706documentText = await extractPdfTextNative(
715} else { // Assume text-like
716const text = await response.text();
717if (!text || text.trim().length === 0) throw new Error("Fetched content is empty or not text.");
718log.push({ agent: ingestionAgent, type: "info", message: `Fetched ~${text.length} characters from URL.` });
719documentText = text;
720}
721} catch (error) {
722const errorMessage = `Failed to fetch or process URL ${input.documentUrl}: ${error.message}`;
723log.push({ agent: ingestionAgent, type: "error", message: errorMessage });
724documentText = null;
cerebras_coderv3index.ts1 match
181182try {
183const response = await fetch("/", {
184method: "POST",
185body: JSON.stringify({
TownieuseUser.tsx4 matches
8const [error, setError] = useState(null);
910const fetchData = async () => {
11try {
12const userEndpoint = new URL(USER_ENDPOINT, window.location.origin);
1314const res = await fetch(userEndpoint);
15const data = await res.json();
16if (!res.ok) {
3334useEffect(() => {
35fetchData();
36}, []);
3738return { data, loading, error, refetch: fetchData };
39}
40