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=4&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 13941 results for "fetch"(2438ms)

townie-126useCreditBalance.tsx6 matches

@dinavinter•Updated 12 hours ago
6 const [loading, setLoading] = useState(true);
7
8 const fetchBalance = async () => {
9 try {
10 const response = await fetch("/api/credit-balance");
11 if (response.ok) {
12 const data = await response.json();
13 setBalance(data.balance);
14 } else {
15 console.error("Failed to fetch balance");
16 }
17 } catch (err) {
18 console.error("Error fetching balance:", err);
19 } finally {
20 setLoading(false);
23
24 useEffect(() => {
25 fetchBalance();
26 }, []);
27
28 return { balance, loading, refetch: fetchBalance };
29}

townie-126useCreateProject.tsx1 match

@dinavinter•Updated 12 hours ago
19 setError(null);
20 try {
21 const res = await fetch(ENDPOINT, {
22 method: "POST",
23 headers: {

townie-126useCreateBranch.tsx1 match

@dinavinter•Updated 12 hours ago
12 setData(null);
13 setError(null);
14 const res = await fetch(ENDPOINT, {
15 method: "POST",
16 body: JSON.stringify({

townie-126useBranches.tsx4 matches

@dinavinter•Updated 12 hours ago
7 const [loading, setLoading] = useState(true);
8
9 const fetchData = async () => {
10 const endpoint = new URL(ENDPOINT, window.location.origin);
11 endpoint.searchParams.append("projectId", projectId);
12
13 const res = await fetch(endpoint)
14 .then(res => res.json());
15 setData(res.branches);
19 useEffect(() => {
20 if (!projectId) return;
21 fetchData();
22 }, [projectId]);
23
24 return { data, loading, refetch: fetchData };
25}

townie-126traces.ts1 match

@dinavinter•Updated 12 hours ago
99 return {
100 type: "error",
101 message: `Error fetching traces: ${e.message}`,
102 };
103 }

townie-126TODOs.md1 match

@dinavinter•Updated 12 hours ago
47<!--
48
49- [x] refetch project data on create/etc
50- [x] Loading favicon
51- [x] Ensure main branch is default selected

townie-126text-editor.ts1 match

@dinavinter•Updated 12 hours ago
166 let type_: "file" | "http" | "script";
167 if (path.includes("backend/index.ts")) type_ = "http";
168 if (file_text?.includes("export default app.fetch")) type_ = "http";
169 if ([".ts", ".tsx", ".js", ".jsx"].some(ext => path.endsWith(ext))) {
170 type_ = "script";

townie-126system_prompt.txt3 matches

@dinavinter•Updated 12 hours ago
216
217 // Inject data to avoid extra round-trips
218 const initialData = await fetchInitialData();
219 const dataScript = `<script>
220 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
263
2645. **API Design:**
265 - `fetch` handler is the entry point for HTTP vals
266 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
267
2686. **Hono Peculiarities:**

townie-126styles.css8 matches

@dinavinter•Updated 12 hours ago
865
866/** slop styles */
867.fetch-result {
868 display: flex;
869 flex-direction: column;
871}
872
873.fetch-header {
874 display: flex;
875 justify-content: space-between;
910}
911
912.fetch-section {
913 margin-top: var(--space-2);
914}
915
916.fetch-section h4 {
917 margin-bottom: var(--space-1);
918 font-size: var(--font-size-5);
919}
920
921.fetch-headers, .fetch-body {
922 font-size: var(--font-size-6);
923 background-color: var(--slate-50);
928}
929
930.red, .fetch-error {
931 color: var(--red);
932}
933
934.fetch-error h4 {
935 margin-bottom: var(--space-1);
936 font-size: var(--font-size-5);
937}
938
939.fetch-error pre {
940 font-size: var(--font-size-6);
941 background-color: var(--red-light);

townie-126stripe-webhook.ts2 matches

@dinavinter•Updated 12 hours ago
47
48 try {
49 // TODO: could not get the SDK working but would be great to use this instead of the fetch
50 //const paymentIntent: Stripe.PaymentIntent = await stripe.paymentIntents.retrieve(session.client_reference_id);
51
52 const response = await fetch(`https://api.stripe.com/v1/payment_intents/${session.client_reference_id}`, {
53 method: 'GET',
54 headers: {

FetchBasic2 file matches

@ther•Updated 4 days ago

GithubPRFetcher

@andybak•Updated 1 week ago