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/$%7Bsuccess?q=fetch&page=699&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 8591 results for "fetch"(1440ms)

http_client_componentmain.tsx1 match

@pomdtr•Updated 1 year ago
87 ),
88 );
89 const resp = await fetch(req);
90 setResponse(resp);
91 }}

sqliteExplorerApp_DEVmain.tsx4 matches

@nbbaier•Updated 1 year ago
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
3import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
4import { sqlToCSV, sqlToJSON } from "https://esm.town/v/nbbaier/sqliteExportHelpers";
14import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder";
15import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
16import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
17import { Hono } from "npm:hono";
18import type { FC } from "npm:hono/jsx";
173});
174
175export const handler = app.fetch;
176export default reloadOnSaveFetchMiddleware(passwordAuth(handler));

codeOnValTownmain.tsx3 matches

@pomdtr•Updated 1 year ago
38
39/**
40 * @param handler Fetch handler
41 * @param val Define which val should open
42 */
43export function modifyFetchHandler(
44 handler: (req: Request) => Response | Promise<Response>,
45 { val, style }: { val?: ValRef; style?: string } = {},
63};
64
65export default modifyFetchHandler;

codeOnValTownREADME.md6 matches

@pomdtr•Updated 1 year 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=45";
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;

webmention_discomain.tsx1 match

@brianleroux•Updated 1 year ago
5 // look for first Link in headers
6 let found = [];
7 let raw = await fetch(source, {
8 redirect: "follow",
9 follow: 10,

leaderboardmain.tsx1 match

@sqlite•Updated 1 year ago
10 const table = stripAnsi(renderTable(zip(res)));
11
12 const resp = await fetch("https://sourcecodeshots.com/api/image", {
13 method: "POST",
14 headers: {

slackBotExamplemain.tsx2 matches

@maxm•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const slackReplyToMessage = async (req: Request) => {
15 // Note: `body.event` has information about the event
16 // like the sender and the message text
17 const result = await fetchJSON(
18 "https://slack.com/api/chat.postMessage",
19 {

nasaAPODmain.tsx2 matches

@henrii•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Returns NASA's Astronomy Picture of the Day (APOD)
4export const nasaAPOD = await fetchJSON("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY");
5console.log(nasaAPOD.url);
6

fetchAndStoreOpenAiUsage2README.md1 match

@nbbaier•Updated 1 year ago
1Migrated from folder: projects/OpenAiUsage/fetchAndStoreOpenAiUsage2

fetchNewPublicGitHubReposmain.tsx3 matches

@stevekrouse•Updated 1 year ago
1export default async function fetchNewPublicGitHubRepos() {
2 // Generate today's date in YYYY-MM-DD format
3 const today = new Date().toISOString().split("T")[0];
9 const url = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=${sort}&order=${order}`;
10
11 const response = await fetch(url, {
12 headers: {
13 "Accept": "application/vnd.github.v3+json",
14 "User-Agent": "Deno-GitHub-Repo-Fetcher", // GitHub API requires a user-agent header
15 },
16 });

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago