Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Burl%7D?q=fetch&page=665&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 9169 results for "fetch"(2041ms)

lastloginREADME.md1 match

@tionis•Updated 8 months ago
38});
39
40export default lastlogin(app.fetch);
41```

lastloginmain.tsx2 matches

@tionis•Updated 8 months ago
95 tokenUrl.searchParams.set("state", store.state);
96
97 const tokenResp = await fetch(tokenUrl.toString());
98 if (!tokenResp.ok) {
99 throw new Error(await tokenResp.text());
104 };
105
106 const resp = await fetch("https://lastlogin.io/userinfo", {
107 headers: {
108 Authorization: `Bearer ${access_token}`,

sqliteExplorerAppmain.tsx4 matches

@rizoadev•Updated 8 months ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { 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});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));

test_migratedmain.tsx1 match

@jxnblk•Updated 8 months ago
76 if (valURL) {
77 try {
78 await fetch(valURL)
79 .then(res => res.json())
80 .then(res => {

textStoragemain.tsx26 matches

@all•Updated 8 months ago
51
52 useEffect(() => {
53 fetchTexts();
54 fetchTemplates();
55 fetchCategories();
56 fetchHistory();
57 }, []);
58
59 const fetchTexts = async () => {
60 const response = await fetch('/texts');
61 const data = await response.json();
62 setTexts(data);
63 };
64
65 const fetchTemplates = async () => {
66 const response = await fetch('/templates');
67 const data = await response.json();
68 setTemplates(data);
69 };
70
71 const fetchCategories = async () => {
72 const response = await fetch('/categories');
73 const data = await response.json();
74 setCategories(data);
75 };
76
77 const fetchHistory = async () => {
78 const response = await fetch('/history');
79 const data = await response.json();
80 setHistory(data);
95 const method = editingText && editingText.id !== 0 ? 'PUT' : 'POST';
96
97 const response = await fetch(url, {
98 method,
99 headers: { 'Content-Type': 'application/json' },
102
103 if (response.ok) {
104 fetchTexts();
105 fetchCategories();
106 fetchHistory();
107 setModalOpen(false);
108 setEditingText(null);
124 const method = 'PUT';
125
126 const response = await fetch(url, {
127 method,
128 headers: { 'Content-Type': 'application/json' },
131
132 if (response.ok) {
133 fetchTemplates();
134 setModalOpen(false);
135 setEditingTemplate(null);
139
140 const deleteText = async (id: number) => {
141 const response = await fetch(`/texts/${id}`, { method: 'DELETE' });
142 if (response.ok) {
143 fetchTexts();
144 fetchCategories();
145 fetchHistory();
146 }
147 };
155 };
156
157 const response = await fetch('/texts', {
158 method: 'POST',
159 headers: { 'Content-Type': 'application/json' },
162
163 if (response.ok) {
164 fetchTexts();
165 fetchCategories();
166 fetchHistory();
167 setActiveTab("texts");
168 }

memeGeneratormain.tsx1 match

@stevekrouse•Updated 8 months ago
30
31 useEffect(() => {
32 fetch("/templates")
33 .then(response => response.json())
34 .then(data => setTemplates(data));

isMyWebsiteDownmain.tsx2 matches

@shreyasmakes•Updated 8 months ago
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }

likelyPinkPuffinmain.tsx5 matches

@stevedylandev•Updated 8 months ago
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 */
6
16];
17
18// Function to fetch recent questions from Stack Overflow for multiple topics
19async function fetchRecentQuestions(): Promise<StackExchange.Question[]> {
20 const allQuestions: StackExchange.Question[] = [];
21
22 for (const topic of TOPICS) {
23 const response = await fetch(
24 `https://api.stackexchange.com/2.3/questions?order=desc&sort=creation&site=stackoverflow&filter=withbody&tagged=${topic}&pagesize=5`,
25 );
48 const { email } = await import("https://esm.town/v/std/email");
49
50 const questions = await fetchRecentQuestions();
51 const htmlContent = formatQuestionsHtml(questions);
52

codeOnValTownREADME.md6 matches

@Serizon•Updated 8 months ago
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return 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:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You 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.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;

codeOnValTownmain.tsx3 matches

@Serizon•Updated 8 months ago
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;

proxyFetch2 file matches

@vidar•Updated 22 hours ago

TAC_FetchBasic2 file matches

@A7_OMC•Updated 1 day ago