9596try {
97const verifyResult = await fetch(verifyUrl, {
98method: "POST",
99body: verifyData,
untitled-1237main.ts1 match
2// import * as fsp from 'fs/promises';
3// import fs from 'fs';
4import { fetch } from "npm:node-fetch";
56(async () => {
4export default async function Index() {
5const BASE = "https://val.town/v/carshimoot.chanmap";
6const res = await fetch(`${BASE}.getPosts`);
7const posts = await res.json() as { id: string; text: string; replies: string[] }[];
84748async function loadPosts() {
49const res = await fetch(BASE + ".getPosts");
50const posts = await res.json();
51const container = document.getElementById("threads");
70threadId: e.target.threadId.value || null
71};
72await fetch(BASE + ".post", {
73method: "POST",
74headers: { "Content-Type": "application/json" },
4445useEffect(() => {
46async function fetchQuote() {
47try {
48const known = await getKnownTexts();
54let waited = 0;
55while (value === undefined && waited <= 10) {
56const response = await fetch(`https://simplevalueapi.val.run/getValue?id=${uuid}`);
57const responseData = await response.json();
58if (responseData?.value?.cipher === undefined) {
95});
96}
97console.log("new uuid, fetching new quote");
98let keyword = "";
99let quote = "";
100let author = "";
101while (quote === "") {
102const response = await fetch(`/quote`);
103const responseData = await response.json();
104if ((responseData?.quote?.length ?? 0) >= 5) {
134}
135} catch (error) {
136console.error("Failed to fetch quote:", error);
137setLoadingError(`${error}`);
138setIsLoading(false);
140}
141142fetchQuote();
143}, []);
144
333formData.append('imageBase64', currentAnalysisSession.imgBase64);
334335const res = await fetch(window.location.pathname + '?format=json', { method: 'POST', body: formData });
336const data = await res.json().catch(() => { throw new Error(\`The server returned an unexpected response. Status: \${res.status}\`); });
337
325currentAnalysisSession.imgSource = \`File: \${currentAnalysisSession.imgName}\`;
326currentAnalysisSession.step = 2;
327fetchAndPopulateSuggestions();
328}
329
419
420if (suggestionsError) {
421document.getElementById('retry-suggestions-btn').addEventListener('click', fetchAndPopulateSuggestions);
422}
423
488const formData = new FormData();
489formData.append('imageFile', file, file.name);
490const res = await fetch(window.location.pathname + '?action=suggestTasks&format=json', { method: 'POST', body: formData });
491const data = await res.json().catch(() => { throw new Error(\`Server error: \${res.status}. Invalid JSON.\`); });
492if (!res.ok || data.error) throw new Error(data.error || \`Server error: \${res.status}\`);
509}
510511async function fetchAndPopulateSuggestions() {
512currentAnalysisSession.isProcessing = true;
513currentAnalysisSession.suggestionsError = null;
518// No need to send the whole file again if we have the base64 string
519formData.append('imageBase64', currentAnalysisSession.imgBase64);
520const res = await fetch(window.location.pathname + '?action=suggestTasks&format=json', { method: 'POST', body: formData });
521const data = await res.json().catch(() => { throw new Error(\`Server returned non-JSON: \${res.status}\`); });
522if (!res.ok || data.error) throw new Error(data.error || \`Server Error: \${res.status}\`);
664formData.append('inputSourceDescription', currentAnalysisSession.imgSource);
665666const res = await fetch(window.location.pathname + '?format=json', { method: 'POST', body: formData });
667const data = await res.json().catch(() => { throw new Error(\`Server error: \${res.status}. Invalid JSON.\`); });
668if (!res.ok || data.error) throw new Error(JSON.stringify(data.error || data.details) || \`Server error: \${res.status}\`);
4344try {
45const response = await fetch("/api/user/username", {
46method: "POST",
47headers: {
2223try {
24const response = await fetch("/auth/magic-link", {
25method: "POST",
26headers: {
luciaMagicLinkStarterindex.ts2 matches
77});
7879// HTTP vals expect an exported "fetch handler"
80// This is how you "run the server" in Val Town with Hono
81export default app.fetch;