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=694&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 8474 results for "fetch"(943ms)

isR18MagzineDownmain.tsx2 matches

@slushyowl•Updated 1 year 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 }

indigoMockingbirdmain.tsx4 matches

@tsoongg•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3const randomJoke = await fetchRandomJoke();
4const setup = randomJoke.setup;
5const punchline = randomJoke.punchline;
9 subject: setup,
10});
11// Fetches a random joke.
12async function fetchRandomJoke() {
13 const response = await fetch(
14 "https://official-joke-api.appspot.com/random_joke",
15 );

Jokemain.tsx4 matches

@zoeecheung•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;

dateme_sqlitemain.tsx2 matches

@stevekrouse•Updated 1 year ago
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { getDocs } from "https://esm.town/v/stevekrouse/getSqliteDateMeDocs";
4import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
36export async function setupDatabase() {
37 await createTable();
38 const docs = await fetchJSON(thisWebURL());
39 return docs.map(args =>
40 sqlite.execute({

bronzeParrotfishmain.tsx3 matches

@shouryaravula19•Updated 1 year ago
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",
10}
11
12const randomJoke = fetchRandomJoke();
13const setup = randomJoke.setup;
14const punchline = randomJoke.punchline;

fetch_docsREADME.md1 match

@andreterron•Updated 1 year ago
1# Proxied fetch - https://docs.val.town/std/fetch

honoBasicAuthmain.tsx4 matches

@mmcc•Updated 1 year ago
18};
19
20async function fetchUser(token: string): Promise<User> {
21 const resp = await fetch("https://api.val.town/v1/me", {
22 headers: {
23 Authorization: `Bearer ${token}`,
26
27 if (resp.status !== 200) {
28 throw new Error("Could not fetch user");
29 }
30
34async function isTokenValid(token) {
35 try {
36 const [visitor, owner] = await Promise.all([fetchUser(token), fetchUser(Deno.env.get("valtown"))]);
37 return visitor.id == owner.id;
38 } catch (err) {

magentaTroutmain.tsx1 match

@stevekrouse•Updated 1 year ago
124export const form = new Hono();
125form.get("/", Form);
126export default form.fetch;

purpleOctopusmain.tsx2 matches

@stevekrouse•Updated 1 year ago
1/** @jsxImportSource https://esm.sh/preact */
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
3import browse from "https://esm.town/v/stevekrouse/dateme_browse";
4import faq from "https://esm.town/v/stevekrouse/dateme_faq";
13app.all("/submit", form);
14app.get("/faq", faq);
15export default modifyFetchHandler(app.fetch, {
16 style: `@media (max-width: 500px) {
17 .github-fork-ribbon {

reloadOnSaveREADME.md3 matches

@stevekrouse•Updated 1 year ago
1# Reload in new tabs when your vals change
2
3When you're working on an HTML HTTP val in a new tab, it's annoying to have to manually reload the tab on every save. In the Val Town editor, you can hit cmd+enter, but there's nothing like that for a val in a new tab because Val Town doesn't control that new tab (like we control the iframe in the browser preview). However, you control that HTML via the fetch handler you're writing, so you can add a script that polls the Val Town API for the current version number of your val, and reload itself if it detects a new version. This val has a collection of helpers to help you do just that.
4
5## Usage
7```ts
8import { html } from "https://esm.town/v/stevekrouse/html";
9import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
10
11export default reloadOnSaveFetchMiddleware(async function(req: Request): Promise<Response> {
12 return html(`<h1>Hello!!</h1>`);
13})

fetchPaginatedData2 file matches

@nbbaier•Updated 2 weeks ago

FetchBasic1 file match

@fredmoon•Updated 2 weeks ago