95tokenUrl.searchParams.set("state", store.state);
9697const tokenResp = await fetch(tokenUrl.toString());
98if (!tokenResp.ok) {
99throw new Error(await tokenResp.text());
104};
105106const resp = await fetch("https://lastlogin.io/userinfo", {
107headers: {
108Authorization: `Bearer ${access_token}`,
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(passwordAuth(handler, { verifyPassword: verifyToken })));
test_migratedmain.tsx1 match
76if (valURL) {
77try {
78await fetch(valURL)
79.then(res => res.json())
80.then(res => {
textStoragemain.tsx26 matches
5152useEffect(() => {
53fetchTexts();
54fetchTemplates();
55fetchCategories();
56fetchHistory();
57}, []);
5859const fetchTexts = async () => {
60const response = await fetch('/texts');
61const data = await response.json();
62setTexts(data);
63};
6465const fetchTemplates = async () => {
66const response = await fetch('/templates');
67const data = await response.json();
68setTemplates(data);
69};
7071const fetchCategories = async () => {
72const response = await fetch('/categories');
73const data = await response.json();
74setCategories(data);
75};
7677const fetchHistory = async () => {
78const response = await fetch('/history');
79const data = await response.json();
80setHistory(data);
95const method = editingText && editingText.id !== 0 ? 'PUT' : 'POST';
9697const response = await fetch(url, {
98method,
99headers: { 'Content-Type': 'application/json' },
102103if (response.ok) {
104fetchTexts();
105fetchCategories();
106fetchHistory();
107setModalOpen(false);
108setEditingText(null);
124const method = 'PUT';
125126const response = await fetch(url, {
127method,
128headers: { 'Content-Type': 'application/json' },
131132if (response.ok) {
133fetchTemplates();
134setModalOpen(false);
135setEditingTemplate(null);
139140const deleteText = async (id: number) => {
141const response = await fetch(`/texts/${id}`, { method: 'DELETE' });
142if (response.ok) {
143fetchTexts();
144fetchCategories();
145fetchHistory();
146}
147};
155};
156157const response = await fetch('/texts', {
158method: 'POST',
159headers: { 'Content-Type': 'application/json' },
162163if (response.ok) {
164fetchTexts();
165fetchCategories();
166fetchHistory();
167setActiveTab("texts");
168}
memeGeneratormain.tsx1 match
3031useEffect(() => {
32fetch("/templates")
33.then(response => response.json())
34.then(data => setTemplates(data));
isMyWebsiteDownmain.tsx2 matches
9let reason: string;
10try {
11const res = await fetch(URL, { redirect: "follow" });
12if (res.status !== 200) {
13reason = `(status code: ${res.status})`;
15}
16} catch (e) {
17reason = `couldn't fetch: ${e}`;
18ok = false;
19}
likelyPinkPuffinmain.tsx5 matches
2* This val creates a cron job that sends an email with recent Stack Overflow posts
3* mentioning various file upload-related topics.
4* It uses the Stack Exchange API to fetch recent questions and the Val Town email API to send the digest.
5*/
616];
1718// Function to fetch recent questions from Stack Overflow for multiple topics
19async function fetchRecentQuestions(): Promise<StackExchange.Question[]> {
20const allQuestions: StackExchange.Question[] = [];
2122for (const topic of TOPICS) {
23const response = await fetch(
24`https://api.stackexchange.com/2.3/questions?order=desc&sort=creation&site=stackoverflow&filter=withbody&tagged=${topic}&pagesize=5`,
25);
48const { email } = await import("https://esm.town/v/std/email");
4950const questions = await fetchRecentQuestions();
51const htmlContent = formatQuestionsHtml(questions);
52
codeOnValTownREADME.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;
codeOnValTownmain.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 }: { val?: ValRef; style?: string } = {},
52}
5354export default modifyFetchHandler;