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=191&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 2766 results for "fetch"(321ms)

OpenTownieapi.ts3 matches

@arfan•Updated 1 month ago
1// Fetch project files from the backend
2export async function fetchProjectFiles(
3 { bearerToken, projectId, branchId }: { bearerToken: string; projectId: string; branchId?: string },
4) {
9 }
10
11 const response = await fetch(url.toString(), {
12 headers: {
13 "Authorization": "Bearer " + bearerToken,

MiniAppStarterindex.ts2 matches

@charmaine•Updated 1 month ago
47});
48
49// HTTP vals expect an exported "fetch handler"
50// This is how you "run the server" in Val Town with Hono
51export default app.fetch;

MiniAppStarterfarcaster.ts1 match

@charmaine•Updated 1 month ago
84
85async function sendFarcasterNotification(payload: any) {
86 return await fetch("https://api.warpcast.com/v1/frame-notifications", {
87 method: "POST",
88 headers: { "Content-Type": "application/json" },
reactstream

reactstreamREADME.md2 matches

@jxnblk•Updated 1 month ago
80```
81
82### Fetch data on the server to set initial props
83
84
86// example middleware
87async function getInitialProps (req: Request, res: Response, next) {
88 // fetch data or do async work to pass as props to the component
89 req.data = {
90 hello: "props",

hn_notifierutils.ts2 matches

@charmaine•Updated 1 month ago
1import { betterFetch, BetterFetchError } from "https://esm.sh/@better-fetch/fetch";
2import { HNAPIResponse } from "https://esm.town/v/nbbaier/hn_notifier/shared/types.ts";
3
22
23export async function getHNItem(id: number) {
24 return await betterFetch<HNAPIResponse>(
25 `${HN_API_URL}/${id}`,
26 );

hn_notifierItemContext.tsx11 matches

@charmaine•Updated 1 month ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { createContext, type ReactNode, useContext, useEffect, useState } from "https://esm.sh/react@18.2.0";
3import { $api } from "https://esm.town/v/nbbaier/hn_notifier/backend/fetchClient.ts";
4import type { DBItem } from "https://esm.town/v/nbbaier/hn_notifier/shared/types.ts";
5
9 saveUrl: (id: number) => Promise<void>;
10 unfollowUrl: (id: number) => Promise<void>;
11 fetchUrls: () => Promise<void>;
12}
13
21 throw new Error("unfollowUrl function not implemented");
22 },
23 fetchUrls: async () => {
24 throw new Error("fetchUrls function not implemented");
25 },
26});
34 const [isLoading, setIsLoading] = useState<boolean>(false);
35
36 // Function to fetch URLs that can be called from components
37 const fetchUrls = async (): Promise<void> => {
38 setIsLoading(true);
39 try {
45 }
46 } catch (error) {
47 console.error("Failed to fetch items:", error);
48 setItems([]);
49 } finally {
53
54 useEffect(() => {
55 fetchUrls();
56 }, []);
57
69 if (data) console.log(`Post ${data.hnId} successfully followed`);
70
71 await fetchUrls(); // Refresh the list after saving
72 } catch (error) {
73 console.error("Failed to add item:", error);
81 try {
82 const { data, error } = await $api(`/unfollow/${id}`);
83 await fetchUrls(); // Refresh the list after unfollowing
84 } catch (error) {
85 console.error("Failed to unfollow item:", error);
94 saveUrl,
95 unfollowUrl,
96 fetchUrls,
97 };
98

hn_notifierindex.ts1 match

@charmaine•Updated 1 month ago
31});
32
33export default app.fetch;

hn_notifierfetchClient.ts2 matches

@charmaine•Updated 1 month ago
1import { createFetch } from "https://esm.sh/@better-fetch/fetch";
2
3export const $api = createFetch({
4 baseURL: "/api",
5});
ditherPng

ditherPngmain.tsx2 matches

@maxm•Updated 1 month ago
11
12async function getImage(url: string) {
13 const data = await fetch(url).then((e) => e.arrayBuffer()).then((e) => new Uint8Array(e));
14 const image = await loadImage(data);
15
28 || "https://64.media.tumblr.com/890467167af5755e783852b43862c5f8/464de28a7bab42a9-2e/s500x750/746aaed1ae2e6b35b28b29643e7a4f84ca5fe8c5.png";
29 if (url.pathname === "/original.png") {
30 return fetch(
31 imgUrl,
32 );

monkepixels.ts1 match

@maxm•Updated 1 month ago
26
27async function getImageFromWeb(path: string) {
28 const res = await fetch(path);
29 if (res.ok) {
30 const data = new Uint8Array(await res.arrayBuffer());

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago