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/?q=fetch&page=650&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 7885 results for "fetch"(1198ms)

blobertDatamain.tsx2 matches

@rvorias•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3const gist =
5
6export const queryParams = async (req: Request) => {
7 const data = await fetch(gist);
8 const jsonData = await data.json();
9

postRequestExamplemain.tsx2 matches

@stevekrouse•Updated 1 year ago
1// make POST fetch to https://stevekrouse-parsePostBodyExample.web.val.run
2console.log(
3 await (await fetch("https://stevekrouse-parsePostBodyExample.web.val.run", {
4 method: "POST",
5 headers: {

googlePhotosMarketingRSSmain.tsx3 matches

@Glench•Updated 1 year ago
1import { dataToRSS } from "https://esm.town/v/Glench/dataToRSS";
2import { fetch } from "https://esm.town/v/std/fetch";
3
4async function getOfficialRedditPosts() {
5 const resp = await fetch("https://www.reddit.com/r/googlephotos/.json");
6 if (!resp.ok) return [];
7 const json = await resp.json();
13}
14async function getGoogleSupportForumPosts() {
15 const resp = await fetch(
16 "https://support.google.com/photos/threads?hl=en&max_results=500",
17 );

todoListScriptmain.tsx1 match

@stevekrouse•Updated 1 year ago
4
5const root = createRoot(document.getElementById("app"));
6let initialTodos = await fetch("https://stevekrouse-todo_list.web.val.run/todos").then(r => r.json());
7root.render(_jsx(TodoApp, { initialTodos: initialTodos }));

esmTownTranspileDemoREADME.md1 match

@stevekrouse•Updated 1 year ago
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`.
6
7The 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.
8
9As of July 23, 2024, this is the code that determines when esm.town transpiles or not:

draggableItemsmain.tsx1 match

@nbbaier•Updated 1 year ago
90});
91
92export default app.fetch;

open_in_valtownmain.tsx1 match

@stevekrouse•Updated 1 year ago
3
4/**
5 * @param handler Fetch handler
6 */
7export default function openInValTown(

isMyWebsiteDownmain.tsx3 matches

@thierryc•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email";
2import { fetch } from "https://esm.town/v/std/fetch";
3
4export const isMyWebsiteDown = async () => {
8 let reason: string;
9 try {
10 const res = await fetch(URL);
11 if (res.status !== 200) {
12 reason = `(status code: ${res.status})`;
14 }
15 } catch (e) {
16 reason = `couldn't fetch: ${e}`;
17 ok = false;
18 }

flydotioRSSmain.tsx1 match

@mstubbs•Updated 1 year ago
3
4export async function flydotioRSS(req: Request): Promise<Response> {
5 const response = await fetch("https://fly.io/blog/");
6 const body = await response.text();
7 const $ = cheerio.load(body);

sendEmailmain.tsx1 match

@thu•Updated 1 year ago
8}
9
10export default app.fetch;
11

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

FetchBasic1 file match

@fredmoon•Updated 1 week ago