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=200&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 2746 results for "fetch"(364ms)

trAIderAgentgetStockAnalysis.ts2 matches

@kamalnrf•Updated 1 month ago
79
80export async function getStockAnalysis(ticker: string) {
81 console.log("Fetching Yahoo Finance data for:", ticker);
82
83 try {
89 }
90
91 return { error: `Unknow error while fetching ${ticker}` };
92 }
93}

farcasterFlingsmain.tsx1 match

@stevekrouse•Updated 1 month ago
1export const farcasterFlings = async () => {
2 let FARCASTER_USERNAME = "whatrocks";
3 let flings = await fetch(
4 `https://searchcaster.xyz/api/search?regex=%E2%8C%86&username=${FARCASTER_USERNAME}`,
5 ).then((res) => res.json());

GitHubSyncREADME.md4 matches

@tionis•Updated 1 month ago
12
13- `/push` will copy the contents from a list of vals specified in `config.json` and push them to a GitHub repo
14- `/deploy` is a GitHub webhook URL that will fetch contents from GitHub and update the code on Val Town
15
161. Fork this val
271. Add a `VAL_SECRET` env var to the val. Use this secret to sign the webhook POST request to the `/push` endpoint. Use this endpoint to commit vals from Val Town to your GitHub repo.
28
29### Example push to GitHub fetch
30
31You can use this example to POST to the `/push` endpoint to copy vals to GitHub.
46 const signature = await sign(body, secret);
47
48 const res = await fetch(url, {
49 method: "POST",
50 body,
89- [x] Monkey test
90- [x] Add setup instructions to readme
91- [x] Add example code for private webhook fetch
92- [x] Make val and repo public
93- [ ] Check modified date before export to GitHub??

GitHubSyncindex1 match

@tionis•Updated 1 month ago
22app.post("/deploy", verifyGitHubSignature(GITHUB_WEBHOOK_SECRET), deploy);
23
24export default app.fetch;

reactHonoExample_toowiredApp.tsx2 matches

@toowired•Updated 1 month ago
18
19 try {
20 const response = await fetch("/api/research", {
21 method: "POST",
22 headers: { "Content-Type": "application/json" },
31 }]);
32 } catch (error) {
33 console.error("Error fetching data:", error);
34 setMessages(prev => [...prev, {
35 text: "Sorry, I encountered an error while researching. Please try again.",

OpenTownieBranchControl.tsx22 matches

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

ATProtoOAuthStartermain.tsx1 match

@charmaine•Updated 1 month ago
139app.get("/callback", (c) => c.json(c.req));
140app.get("/client-metadata.json", (c) => c.json(clientMetadata));
141export default app.fetch;

spagindex.html6 matches

@seventeenthmagpie•Updated 1 month ago
231 uploadButton.disabled = true;
232 uploadButton.textContent = "Uploading...";
233 const response = await fetch("/api/upload", {
234 method: "POST",
235 body,
251 );
252
253 async function fetchUploads() {
254 const response = await fetch("/api/list");
255 const data = await response.json();
256 return data.rows;
261 previewAllButton.hidden = true;
262 refreshButton.textContent = "Refreshing...";
263 const uploads = await fetchUploads();
264 renderUploads(uploads);
265 refreshButton.textContent = "Refresh";
311 previewContainer.innerHTML = "";
312 try {
313 fetch(`https://spag.cc/${upload.name}`).then(async (response) => {
314 if (!response.ok) {
315 const textElement = document.createElement("p");
395 deleteButton.disabled = true;
396 deleteButton.textContent = "Deleting...";
397 const response = await fetch(
398 `/api/delete`,
399 {

spagindex.html6 matches

@froos•Updated 1 month ago
231 uploadButton.disabled = true;
232 uploadButton.textContent = "Uploading...";
233 const response = await fetch("/api/upload", {
234 method: "POST",
235 body,
251 );
252
253 async function fetchUploads() {
254 const response = await fetch("/api/list");
255 const data = await response.json();
256 return data.rows;
261 previewAllButton.hidden = true;
262 refreshButton.textContent = "Refreshing...";
263 const uploads = await fetchUploads();
264 renderUploads(uploads);
265 refreshButton.textContent = "Refresh";
311 previewContainer.innerHTML = "";
312 try {
313 fetch(`https://spag.cc/${upload.name}`).then(async (response) => {
314 if (!response.ok) {
315 const textElement = document.createElement("p");
395 deleteButton.disabled = true;
396 deleteButton.textContent = "Deleting...";
397 const response = await fetch(
398 `/api/delete`,
399 {

OpenTownieCreateBranch.tsx1 match

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

fetchPaginatedData2 file matches

@nbbaier•Updated 6 days ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago