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=193&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 2759 results for "fetch"(335ms)

svgRendererideaScore-renderer.ts3 matches

@dcm31•Updated 1 month ago
3
4export const handler = {
5 async fetch(req: Request) {
6 // IdeaScore logo SVG code - Using standard SVG attribute naming with dashes
7 const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 301 113.266" width="301" height="113.266">
67};
68
69// Export the fetch handler for Val Town
70export default handler.fetch;

svgRendererinstagram-logo-renderer.ts3 matches

@dcm31•Updated 1 month ago
3
4export const handler = {
5 async fetch(req: Request) {
6 // Instagram logo SVG code with green gradient
7 const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
49};
50
51// Export the fetch handler for Val Town
52export default handler.fetch;

mynewprojectjxnReactStream4 matches

@stevekrouse•Updated 1 month ago
6
7export type RequestHandler = (request: Request) => Promise<Response>;
8export type DataFetcher<T> = (request: Request) => Promise<T>;
9
10// export type DataRequest<T> = Request & { data: T };
132 return api(req);
133};
134const deprecatedGetInitiaProps = (getProps: DataFetcher<any>): Middleware => async (req, res, next) => {
135 if (!getProps) return next();
136 const data = await getProps(req);
144 /** DEPRECATED: Optional API request handler for all non-GET methods */
145 api?: RequestHandler;
146 /** DEPRECATED: data fetcher to set initial props based on request */
147 getInitialProps?: DataFetcher<any>;
148}

openTownieMadeThis1index.ts2 matches

@stevekrouse•Updated 1 month ago
1import { Hono } from "https://esm.sh/hono@3.12.6";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@71-main/index.ts";
3import { reloadOnSaveFetchMiddleware, currentProjectRef } from "https://esm.town/v/charmaine/reloadOnSaveProject/reloadOnSaveProject.ts";
4
5const app = new Hono();
52
53// This is the entry point for HTTP vals
54export default reloadOnSaveFetchMiddleware(app.fetch);

openTownieMadeThis1index.js6 matches

@stevekrouse•Updated 1 month ago
74
75 try {
76 const response = await fetch('/api/hotels');
77 const hotels = await response.json();
78
90 alert('Hotel search results would display here in a real implementation');
91 } catch (error) {
92 console.error('Error fetching hotels:', error);
93 }
94 });
102 getOfferDetailsBtn.addEventListener('click', async () => {
103 try {
104 const response = await fetch('/api/offers');
105 const offers = await response.json();
106 const mainOffer = offers[0]; // Get the first offer (Anniversary offer)
108 alert(`Offer Details: ${mainOffer.title}\n\n${mainOffer.details}`);
109 } catch (error) {
110 console.error('Error fetching offer details:', error);
111 }
112 });
114 viewAllOffersBtn.addEventListener('click', async () => {
115 try {
116 const response = await fetch('/api/offers');
117 const offers = await response.json();
118
120 alert(`All Available Offers:\n\n${offersList}`);
121 } catch (error) {
122 console.error('Error fetching all offers:', error);
123 }
124 });

svgRenderersvgRenderer.ts3 matches

@dcm31•Updated 1 month ago
36 */
37export const handler = {
38 async fetch(req: Request) {
39 // Get the SVG content from the request query parameters
40 const url = new URL(req.url);
64};
65
66// Export the default fetch handler
67export default handler.fetch;

OpenTowniesystem_prompt.txt5 matches

@loading•Updated 1 month ago
71```
72
735. **fetchTranspiledJavaScript** - Fetch and transpile TypeScript to JavaScript:
74```ts
75const jsCode = await fetchTranspiledJavaScript("https://esm.town/v/username/project/path/to/file.ts");
76```
77
200
201 // Inject data to avoid extra round-trips
202 const initialData = await fetchInitialData();
203 const dataScript = `<script>
204 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
258
2595. **API Design:**
260 - `fetch` handler is the entry point for HTTP vals
261 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
262 - Properly handle CORS if needed for external access

OpenTownieCreateBranch.tsx1 match

@loading•Updated 1 month ago
43
44 try {
45 const response = await fetch("/api/create-branch", {
46 method: "POST",
47 headers: {

OpenTownieBranchControl.tsx22 matches

@loading•Updated 1 month ago
30 const [showCreateBranch, setShowCreateBranch] = useState<boolean>(false);
31
32 // Fetch branches when project changes
33 useEffect(() => {
34 if (!projectId) return;
35
36 const fetchBranches = async () => {
37 setIsLoadingBranches(true);
38 try {
39 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
40 headers: {
41 "Authorization": `Bearer ${bearerToken}`,
44
45 if (!response.ok) {
46 throw new Error(`Failed to fetch branches: ${response.statusText}`);
47 }
48
49 const data = await response.json();
50 const fetchedBranches = data.branches || [];
51 setBranches(fetchedBranches);
52
53 // Check if the stored branchId is valid for this project
54 const storedBranchIsValid = fetchedBranches.some((branch: Branch) => branch.id === branchId);
55
56 // Only set a new branchId if there isn't a valid one already stored
57 if (!storedBranchIsValid && fetchedBranches.length > 0) {
58 // If branches are loaded and there's a "main" branch, select it by default
59 const mainBranch = fetchedBranches.find((branch: Branch) => branch.name === "main");
60 if (mainBranch) {
61 setBranchId(mainBranch.id);
63 } else {
64 // Otherwise select the first branch
65 setBranchId(fetchedBranches[0].id);
66 setSelectedBranchName(fetchedBranches[0].name);
67 }
68 } else if (storedBranchIsValid) {
69 // Set the selected branch name based on the stored branchId
70 const selectedBranch = fetchedBranches.find((branch: Branch) => branch.id === branchId);
71 if (selectedBranch) {
72 setSelectedBranchName(selectedBranch.name);
74 }
75 } catch (error) {
76 console.error("Error fetching branches:", error);
77 } finally {
78 setIsLoadingBranches(false);
80 };
81
82 fetchBranches();
83 }, [projectId, bearerToken, branchId, setBranchId]);
84
105 // Refresh the branches list
106 if (projectId) {
107 const fetchBranches = async () => {
108 try {
109 const response = await fetch(`/api/project-branches?projectId=${projectId}`, {
110 headers: {
111 "Authorization": `Bearer ${bearerToken}`,
114
115 if (!response.ok) {
116 throw new Error(`Failed to fetch branches: ${response.statusText}`);
117 }
118
119 const data = await response.json();
120 const fetchedBranches = data.branches || [];
121 setBranches(fetchedBranches);
122
123 // Update the selected branch name
124 const selectedBranch = fetchedBranches.find((branch: Branch) => branch.id === newBranchId);
125 if (selectedBranch) {
126 setSelectedBranchName(selectedBranch.name);
127 }
128 } catch (error) {
129 console.error("Error fetching branches:", error);
130 }
131 };
132
133 fetchBranches();
134 }
135 };

md_crawlcrawler.ts.fixed2 matches

@stevekrouse•Updated 1 month ago
70): Promise<CrawlResult> {
71 try {
72 const response = await fetch(url, {
73 headers: {
74 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
77
78 if (!response.ok) {
79 throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
80 }
81

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago