JimeluStevensApp.tsx17 matches
82const [cookieAndTeaMode, setCookieAndTeaMode] = useState(false);
8384// Fetch images from backend instead of blob storage directly
85useEffect(() => {
86// Set default background color in case image doesn't load
89}
9091// Fetch avatar image
92fetch("/api/images/stevens.jpg")
93.then((response) => {
94if (response.ok) return response.blob();
103});
104105// Fetch wood background
106fetch("/api/images/wood.jpg")
107.then((response) => {
108if (response.ok) return response.blob();
129}, []);
130131const fetchMemories = useCallback(async () => {
132setLoading(true);
133setError(null);
134try {
135const response = await fetch(API_BASE);
136if (!response.ok) {
137throw new Error(`HTTP error! status: ${response.status}`);
154}
155} catch (e) {
156console.error("Failed to fetch memories:", e);
157setError(e.message || "Failed to fetch memories.");
158} finally {
159setLoading(false);
162163useEffect(() => {
164fetchMemories();
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
176177try {
178const response = await fetch(API_BASE, {
179method: "POST",
180headers: { "Content-Type": "application/json" },
188setNewMemoryTags("");
189setShowAddForm(false);
190await fetchMemories();
191} catch (e) {
192console.error("Failed to add memory:", e);
199200try {
201const response = await fetch(`${API_BASE}/${id}`, {
202method: "DELETE",
203});
205throw new Error(`HTTP error! status: ${response.status}`);
206}
207await fetchMemories();
208} catch (e) {
209console.error("Failed to delete memory:", e);
231232try {
233const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
234method: "PUT",
235headers: { "Content-Type": "application/json" },
240}
241setEditingMemory(null);
242await fetchMemories();
243} catch (e) {
244console.error("Failed to update memory:", e);
notionboxdsync.ts2 matches
38const rssURL = process.env.RSS_URL!;
3940const rss = await fetch(rssURL).then(res => {
41if (res.status !== 200) {
42throw new Error("Failed to fetch RSS");
43}
44
BingImageOfDayindex.tsx7 matches
3import { blob } from "https://esm.town/v/std/blob";
4import { backupBingImage } from "./backupImage.tsx";
5import { fetchBingImage } from "./fetchBingImage.tsx";
67const app = new Hono();
51app.get("/", async (c) => {
52try {
53// Use our helper function to fetch the current Bing image
54const response = await fetchBingImage();
55if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
5664});
65} catch (error) {
66return c.json({ error: "Failed to fetch current Bing image" }, 500);
67}
68});
84path: "/",
85method: "GET",
86description: "Fetches the current Bing Image of the Day.",
87response: "JPEG image with headers `Content-Type: image/jpeg`.",
88},
96path: "/get/:date",
97method: "GET",
98description: "Fetches a saved Bing Image of the Day for a specific date.",
99urlParams: "date - format: MM-DD-YYYY",
100response: "JPEG image or JSON error if not found.",
120121// This is the entry point for HTTP vals
122export default app.fetch;
16const lastRunAt = new Date(lastRun?.date);
17const content = lastRun?.content;
18const fetchURL = [
19"https://" + subdomain + ".val.run",
20lastRun?.path,
42// (note the x-blob-key header)
43if (content != "default" && diffInMinutes > .5) {
44const response = await fetch(fetchURL, {
45method: "POST",
46headers: {
Glancerhelpers.ts3 matches
28const origin = parsedUrl.origin;
2930// Fetch the HTML from the URL
31const response = await fetch(url);
32const html = await response.text();
336263// Verify the favicon exists
64const faviconResponse = await fetch(faviconUrl, { method: "HEAD" });
6566if (!faviconResponse.ok) {
practicalAquaWaspmain.tsx2 matches
1/** @jsxImportSource https://esm.sh/react */
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
34const exampleJSX = <p>Hello, World!</p>;
56console.log(
7await fetchText("https://esm.town/v/moe/HonoReactTailwindStarter@48-deptest/frontend/index.tsx", {
8headers: {
9"User-Agent": "", // can't include Deno, which on Val Town it would by default
practicalAquaWaspREADME.md1 match
5It doesn't do as much as other transpilers (such as esm.sh, such as rewriting `npm:` imports, etc). We may add that capability in the future. For now, if you want your npm imports to run in the browser, use `https://esm.sh/package` instead of `npm:package`.
67The below script demonstrates this transiplation behavior by fetching its own source code (`import.meta.url`) with the user agent of a browser. You can uncoment the line setting the browser agent if you want to see the difference in the output. Or you could just load this val's module URL in your browser to see the untranspiled TS.
89As of July 23, 2024, this is the code that determines when esm.town transpiles or not:
filterValsmain.tsx2 matches
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
23export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4const token = Deno.env.get("valtown");
5const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6headers: { Authorization: `Bearer ${token}` },
7});
filterValsmain.tsx2 matches
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2console.log('hi')
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4const token = Deno.env.get("valtown");
5const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6headers: { Authorization: `Bearer ${token}` },
7});
valreadmegeneratormain.tsx1 match
4243try {
44const response = await fetch(`/generate-readme/${user}/${val}`);
4546if (!response.ok) {