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=196&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 2748 results for "fetch"(467ms)

OpenTownieNormalCreateBranch.tsx1 match

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

OpenTownieNormalBranchControl.tsx22 matches

@dcm31•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 };

cerebras_coderindex1 match

@shubhamvavdi•Updated 1 month ago
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
8 headers: {
9 "User-Agent": "", // to transpile TS to JS

cerebras_coderindex1 match

@shubhamvavdi•Updated 1 month ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({

MiniAppStarterindex.ts2 matches

@codyb•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

@codyb•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" },

openTownieMadeThis1index.js6 matches

@charmaine•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 });

MiniAppStarterWeather4 matches

@Metamorphosis0e•Updated 1 month ago
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
14 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}&current_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
15 );
17 setWeatherData(data);
18 } catch (err) {
19 setError("Could not fetch weather data");
20 }
21 }
22
23 fetchWeather();
24 }, [location]);
25

MiniAppStarterindex.ts2 matches

@Metamorphosis0e•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

@Metamorphosis0e•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" },

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago