denoBlogAPImain.tsx1 match
5export default async function main(req: Request): Promise<Response> {
6const url = "https://deno.com/blog";
7const response = await fetch(url);
8const html = await response.text();
9
bulletinBoardmain.tsx7 matches
1415useEffect(() => {
16fetchPosts();
17const interval = setInterval(fetchPosts, 30000); // Refresh every 30 seconds
18return () => clearInterval(interval);
19}, []);
2021const fetchPosts = async () => {
22const response = await fetch("/posts");
23const data = await response.json();
24setPosts(data);
28e.preventDefault();
29setError("");
30const response = await fetch("/post", {
31method: "POST",
32headers: { "Content-Type": "application/json" },
36setNewTitle("");
37setNewPost("");
38fetchPosts();
39} else {
40const error = await response.text();
112const url = new URL(request.url);
113if (url.pathname === "/posts") {
114// Fetch posts
115const posts = await sqlite.execute(`
116SELECT * FROM ${TABLE_NAME}
canvasvalcontributionchartmain.tsx6 matches
1async function fetchContributionData() {
2try {
3const response = await fetch('https://ejfox-allvals.web.val.run');
4if (!response.ok) {
5throw new Error(`HTTP error! status: ${response.status}`);
8return processContributionData(data.vals);
9} catch (error) {
10console.error('Error fetching contribution data:', error);
11throw error;
12}
80async function server(request: Request): Promise<Response> {
81try {
82console.log('Fetching contribution data...');
83const contributionData = await fetchContributionData();
84console.log('Contribution data fetched successfully');
8586const width = 53 * (10 + 4) - 4; // 53 weeks * (10px cell + 4px gap) - 4px (no gap after last week)
valcontributionchartmain.tsx4 matches
1// This approach will fetch data from the specified endpoint, process it to create a GitHub-style contribution chart,
2// and render it using React. We'll use the fetch API to get the data, process it to create a heatmap-like structure,
3// and then use CSS Grid to render the chart with varying shades of green based on the number of vals created each day.
41213useEffect(() => {
14fetch('https://ejfox-allvals.web.val.run')
15.then(response => response.json())
16.then(data => {
20})
21.catch(error => {
22console.error('Error fetching data:', error);
23setLoading(false);
24});
1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
122123export default codeOnValTownBanner(
124passwordAuth(app.fetch, { verifyPassword: verifyToken }),
125);
knowledgeExplorermain.tsx10 matches
17const [activeButton, setActiveButton] = useState(null);
1819const fetchContent = useCallback(async (prompt, direction) => {
20setLoading(true);
21try {
22const response = await fetch("/generate", {
23method: "POST",
24headers: { "Content-Type": "application/json" },
30setContent(newContent);
31} catch (error) {
32console.error("Error fetching content:", error);
33setContent("An error occurred while fetching content.");
34}
35setLoading(false);
39e.preventDefault();
40if (topic) {
41fetchContent(`Provide a concise overview of ${topic} in about 3-4 sentences. Focus on key points and interesting facts. Format your response as follows:
42Title: [A short, catchy title for the topic]
4352setActiveButton("right");
53setTimeout(() => setActiveButton(null), 300);
54fetchContent(`Based on the topic "${title}" and the following information: "${content}", explore a semantically related topic. Provide a brief overview of this new topic, highlighting its connection to ${title}. Format your response as follows:
55Title: [A short, catchy title for the new related topic]
5659setActiveButton("down");
60setTimeout(() => setActiveButton(null), 300);
61fetchContent(`Given the overview of ${title}: "${content}", choose a directly related subtopic or aspect of ${title}. Provide a detailed explanation of this subtopic, focusing on its significance and relationship to the main topic. Format your response as follows:
62Title: [A short, catchy title for the subtopic]
6365}
66}
67}, [fetchContent, title, content]);
6869useEffect(() => {
110🏠 Home
111</button>
112<button className={`right-button ${activeButton === 'right' ? 'active' : ''}`} onClick={() => fetchContent(`Based on the topic "${title}" and the following information: "${content}", explore a semantically related topic. Provide a brief overview of this new topic, highlighting its connection to ${title}. Format your response as follows:
113Title: [A short, catchy title for the new related topic]
114116➡️ Related Topic
117</button>
118<button className={`down-button ${activeButton === 'down' ? 'active' : ''}`} onClick={() => fetchContent(`Given the overview of ${title}: "${content}", choose a directly related subtopic or aspect of ${title}. Provide a detailed explanation of this subtopic, focusing on its significance and relationship to the main topic. Format your response as follows:
119Title: [A short, catchy title for the subtopic]
120
1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
122123export default codeOnValTownBanner(
124passwordAuth(app.fetch, { verifyPassword: verifyToken }),
125);
outsideBlushShrimpmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
52}
5354export default modifyFetchHandler;
outsideBlushShrimpREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
crazyPeachCrayfishREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;