89const app = new Hono();
10export default app.fetch;
1112const baseUrl = "https://spacex.page";
151152// TODO: refactor to notification sending func
153const res = await fetch(notificationUrl, {
154method: "POST",
155headers: { "Content-Type": "application/json" },
24});
2526// HTTP vals expect an exported "fetch handler"
27// This is how you "run the server" in Val Town with Hono
28export default app.fetch;
29
23const [runsResponse, setRunsResponse] = useState<RunsResponse>({ records: [] });
2425const fetchRuns = () => agent.com.atproto.repo
26.listRecords({ collection: "me.wilb.test.run", repo: session.did })
27.then(res => setRunsResponse(res.data as unknown as RunsResponse))
29const deleteRun = (rkey: string) => agent.com.atproto.repo
30.deleteRecord({ collection: "me.wilb.test.run", repo: session.did, rkey })
31.then(() => fetchRuns())
3233return (
39{session && <button
40type="button"
41onClick={fetchRuns}>
42Get my runs
43</button>}
337338useEffect(() => {
339async function fetchQuote() {
340try {
341let loadedFromUUID = false;
342if (uuid) {
343const response = await fetch(`https://bao-simplevalueapi.web.val.run/getValue?id=${uuid}`);
344const responseData = await response.json();
345368while (quote === "") {
369const randomId = Math.floor(Math.random() * quoteCount) + 1;
370const response = await fetch(`/quote?pageId=${randomId}`);
371const responseData = await response.json();
372if ((responseData?.quote?.length ?? 0) >= 70) {
387setQuoteAuthor(author);
388if (uuid) {
389const writeResult = await fetch("https://bao-simplevalueapi.web.val.run/setValue", {
390method: "POST",
391headers: {
408}
409} catch (error) {
410console.error("Failed to fetch quote:", error);
411setLoadingError(`${error}`);
412setIsLoading(false);
414}
415416fetchQuote();
417}, []);
418544545if (uuid && name) {
546await fetch("https://bao-simplevalueapi.web.val.run/addLog", {
547method: "POST",
548headers: {
560}
561if (!isMatch && uuid && name) {
562await fetch("https://bao-simplevalueapi.web.val.run/addLog", {
563method: "POST",
564headers: {
584appendToLocalStorage(cipher.original, quoteAuthor);
585if (uuid && name) {
586const writeResult = await fetch("https://bao-simplevalueapi.web.val.run/addLog", {
587method: "POST",
588headers: {
1211const databaseId = "16e2c190bff080fd9ea8d2a8c21548b0";
12121213// Use database query with filter instead of direct page fetch
1214const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
1215method: "POST",
1216headers: {
12531254let keyword = "";
1255console.log(`Fetched ${data.results.length} pages from Notion API:`);
1256for (const page of data.results) {
1257// console.log("Checking page", page.properties.ID);
24});
2526// HTTP vals expect an exported "fetch handler"
27// This is how you "run the server" in Val Town with Hono
28export default app.fetch;
29
keyboardNtfymain.tsx2 matches
36// 2️⃣ send to ntfy via the server‑side proxy
37try {
38const res = await fetch(`/${NTFY_TOPIC}`, {
39method: "POST",
40headers: { "Content-Type": "application/json" },
150};
151152const ntfyResponse = await fetch(ntfyUrl, {
153method: "POST",
154headers: { "Content-Type": "application/json" },
67const getTextFromUrl = async (url) => {
8const response = await fetch("https://r.jina.ai/"+url);
9const text = await response.text();
10return text;
44});
4546export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
47
52useEffect(() => {
53if (!userId) return;
54const fetchData = async () => {
55setLoading(true);
56try {
59let gd = dg;
60try {
61const gr = await fetch("/api/characters");
62if (gr.ok) {
63const fg = await gr.json();
64if (Array.isArray(fg) && fg.length > 0) gd = fg;
65} else console.warn(`Global fetch fail: ${gr.status}`);
66} catch (e) {
67console.error("Err fetch global:", e);
68}
69setCharacters(gd);
70let pd = dp;
71try {
72const pr = await fetch(`/api/personal-characters?userId=${userId}`);
73if (pr.ok) {
74const fp = await pr.json();
75if (Array.isArray(fp) && fp.length > 0) pd = fp;
76} else console.warn(`Personal fetch fail: ${pr.status}`);
77} catch (e) {
78console.error("Err fetch personal:", e);
79}
80setPersonalCharacters(pd);
81} catch (e) {
82console.error("Err fetchData:", e);
83setCharacters([...CHARACTERS.map(c => ({ ...c }))]);
84setPersonalCharacters([...CHARACTERS.map(c => ({ ...c }))]);
87}
88};
89fetchData();
90}, [userId]);
91useEffect(() => {
160console.log("Attempting to save rankings...");
161162const globalUpdate = fetch("/api/update-rankings", {
163method: "POST",
164headers: { "Content-Type": "application/json" },
166body: JSON.stringify(updatedGlobalChars),
167});
168const personalUpdate = fetch("/api/update-personal-rankings", {
169method: "POST",
170headers: { "Content-Type": "application/json" },
16setError(null);
17try {
18const response = await fetch('/generate-character', { method: 'POST' });
19if (!response.ok) {
20throw new Error(`HTTP error! status: ${response.status}`);
githubNotificationmain.tsx2 matches
1import { email } from "https://esm.town/v/std/email?v=11";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
34export async function githubNotification({ lastRunAt }) {
5let events = (
6await fetchJSON(
7"https://api.github.com/users/worrydream/events",
8) || []