untitled_azureWhippetmain.tsx4 matches
1import { email } from "https://esm.town/v/std/email?v=9";
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
7);
9}
1011const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
hungryWhiteLeoponmain.tsx16 matches
1/**
2* This application helps users write detailed reviews of coffee shops. It fetches coffee shop data
3* from the OpenStreetMap Nominatim API, allows users to add custom details, and stores the augmented
4* information in a SQLite database. The app provides a user interface to view, add, and edit coffee shop reviews.
2526useEffect(() => {
27fetchReviews();
28}, []);
2930const fetchCoffeeShops = async () => {
31try {
32const response = await fetch(`/api/coffee-shops?search=${encodeURIComponent(searchTerm)}`);
33if (!response.ok) throw new Error("Failed to fetch coffee shops");
34const data = await response.json();
35setCoffeeShops(data);
36} catch (error) {
37console.error("Error fetching coffee shops:", error);
38}
39};
4041const fetchReviews = async () => {
42try {
43const response = await fetch("/api/reviews");
44if (!response.ok) throw new Error("Failed to fetch reviews");
45const data = await response.json();
46setReviews(data);
47} catch (error) {
48console.error("Error fetching reviews:", error);
49}
50};
6061try {
62const response = await fetch("/api/reviews", {
63method: "POST",
64headers: { "Content-Type": "application/json" },
75additionalNotes: "",
76});
77fetchReviews();
78} catch (error) {
79console.error("Error submitting review:", error);
91placeholder="Search for coffee shops"
92/>
93<button onClick={fetchCoffeeShops}>Search</button>
94</div>
95<div className="results-section">
194if (url.pathname === "/api/coffee-shops") {
195const searchTerm = url.searchParams.get("search") || "";
196// Fetch coffee shops from OpenStreetMap Nominatim API
197const nominatimUrl = `https://nominatim.openstreetmap.org/search?q=coffee+${
198encodeURIComponent(searchTerm)
199}&format=json&addressdetails=1`;
200const nominatimResponse = await fetch(nominatimUrl, {
201headers: {
202"User-Agent": "CoffeeShopReviewer/1.0",
224if (request.method === "GET") {
225const reviews = await sqlite.execute(`SELECT * FROM ${KEY}_coffee_reviews_${SCHEMA_VERSION}`);
226console.log("Fetched reviews:", reviews.rows);
227return new Response(JSON.stringify(reviews.rows), {
228headers: { "Content-Type": "application/json" },
1920useEffect(() => {
21fetchMessages();
22}, []);
2324const fetchMessages = async () => {
25const response = await fetch("/messages");
26const data = await response.json();
27setMessages(data);
32if (!newMessage.trim()) return;
3334await fetch("/messages", {
35method: "POST",
36headers: { "Content-Type": "application/json" },
3940setNewMessage("");
41fetchMessages();
42};
43
isMyWebsiteDownmain.tsx2 matches
14start = performance.now();
15try {
16const res = await fetch(url);
17end = performance.now();
18status = res.status;
25} catch (e) {
26end = performance.now();
27reason = `couldn't fetch: ${e}`;
28ok = false;
29console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
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(handler, { verifyPassword: verifyToken }));
valTownUsermain.tsx1 match
9cachedUser = await api('/v1/me', { authenticated: true });
10} catch (error) {
11console.error('Error fetching user info:', error);
12return null;
13}
1617while (true) {
18const resp = await fetch(url);
19if (!resp.ok) {
20throw new Error(await resp.text());
33return { data } as T;
34}
35const resp = await fetch(`${API_URL}${path}`, {
36...options,
37headers: {
valTownDataLogsmain.tsx1 match
8788} catch (error) {
89console.error('Error fetching user data or inspecting database:', error);
90}
91}
valTownUserREADME.md1 match
67### getUserInfo()
8Fetches and caches the user's information.
9- Use case: Retrieving all user details at once.
10```ts
32debugMessages.push(`User ID retrieved: ${user.id}`);
3334debugMessages.push(`Fetching vals for user ID: ${user.id}`);
35let vals = [];
36try {
38vals.push(val);
39}
40debugMessages.push(`Vals fetched successfully. Number of vals: ${vals.length}`);
41} catch (error) {
42debugMessages.push(`Error fetching vals: ${error instanceof Error ? error.message : String(error)}`);
43throw new Error(`Failed to fetch vals for user ID: ${user.id}`);
44}
45