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/image-url.jpg?q=fetch&page=1&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 8143 results for "fetch"(930ms)

wonderfulBlushMagpiemain.tsx6 matches

@bgtgtgfgvbtgvgbβ€’Updated 47 mins ago
11
12 useEffect(() => {
13 fetchShorts();
14 }, []);
15
16 const fetchShorts = async () => {
17 try {
18 const response = await fetch('/get-shorts');
19 const data = await response.json();
20 setShorts(data);
21 } catch (err) {
22 console.error('Failed to fetch shorts', err);
23 }
24 };
40
41 try {
42 const response = await fetch('/add-short', {
43 method: 'POST',
44 headers: {
50 if (response.ok) {
51 setNewShortLink('');
52 fetchShorts();
53 }
54 } catch (err) {

instagram-toolsfollows-check.jsx4 matches

@julianperaβ€’Updated 54 mins ago
1import makeFetchCookie from "npm:fetch-cookie";
2const fetchCookie = makeFetchCookie(fetch);
3
4export default async function handleCron(interval) {
5 const following = await fetchCookie(
6 "https://www.instagram.com/api/v1/friendships/375942300/following/?query=miguelse10",
7 {
16 const isFollowing = following.users.some((user) => user.username === "miguelse10");
17
18 const pushNotification = await fetchCookie("https://ntfy.sh/alEMfLpdpoXMe6jB", {
19 method: "POST",
20 body: `Mafalda ${isFollowing ? "lo estΓ‘ siguiendo" : "no lo estΓ‘ siguiendo"} a Miguel.`,
139 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
140
141 const response = await fetch(url, {
142 method: "PATCH",
143 headers: {
77 console.log("Current PR labels:", currentLabels);
78
79 // Fetch labels from all linked issues
80 const repo = payload.repository.full_name;
81 let allIssueLabels: string[] = [];
82
83 for (const issueNumber of issueNumbers) {
84 console.log(`Fetching labels for issue #${issueNumber}`);
85 try {
86 const issue = await fetchIssue(repo, issueNumber);
87 const issueLabels = issue.labels.map(label => label.name);
88 console.log(`Labels for issue #${issueNumber}:`, issueLabels);
95 }
96 } catch (error) {
97 console.error(`Error fetching issue #${issueNumber}:`, error);
98 }
99 }
154}
155
156// Fetch issue details
157async function fetchIssue(repo: string, issueNumber: number): Promise<GitHubIssue> {
158 const token = Deno.env.get("GITHUB_TOKEN");
159
164 const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
165
166 const response = await fetch(url, {
167 headers: {
168 "Authorization": `token ${token}`,
180 // If we can't parse the error as JSON, use the status text
181 }
182 throw new Error(`Failed to fetch issue: ${errorMessage}`);
183 }
184
197 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
198
199 const response = await fetch(url, {
200 method: "POST",
201 headers: {
108 // Get detailed PR info including checks status
109 try {
110 const prDetails = await fetchPRDetails(payload.repository.full_name, payload.pull_request.number);
111 console.log(`PR mergeable status: ${prDetails.mergeable}, state: ${prDetails.mergeable_state}`);
112
130 return new Response("Notification sent to Slack", { status: 200 });
131 } catch (prError) {
132 console.error("Error fetching PR details or sending notification:", prError);
133 return new Response(`Error: ${prError.message}`, { status: 500 });
134 }
211}
212
213// Fetch detailed PR information including checks status
214async function fetchPRDetails(repo: string, prNumber: number) {
215 const token = Deno.env.get("GITHUB_TOKEN");
216 if (!token) {
223 let response;
224 try {
225 response = await fetch(url, {
226 headers: {
227 "Authorization": `token ${token}`,
230 },
231 });
232 } catch (fetchError) {
233 throw new Error(`Network error fetching PR details: ${fetchError.message}`);
234 }
235
236 if (!response.ok) {
237 throw new Error(`Failed to fetch PR details: ${response.status} ${response.statusText}`);
238 }
239
255 // First, verify the PR is still mergeable
256 try {
257 const prDetails = await fetchPRDetails(repo, prNumber);
258
259 if (!prDetails.mergeable) {
284 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
285
286 const response = await fetch(url, {
287 method: "PUT",
288 headers: {
415
416 // Send message to Slack
417 const response = await fetch(slackWebhookUrl, {
418 method: "POST",
419 headers: {
101 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
102
103 const response = await fetch(url, {
104 method: "POST",
105 headers: {
132 console.log("πŸ” Sending assignee request to:", url);
133
134 const response = await fetch(url, {
135 method: "POST",
136 headers: {
170
171 // Get detailed PR info including checks status
172 console.log("πŸ” Fetching detailed PR info...");
173 try {
174 const prDetails = await fetchPRDetails(repository.full_name, pull_request.number);
175 console.log("πŸ” PR details fetched successfully");
176 console.log("πŸ” PR mergeable status:", prDetails.mergeable);
177 console.log("πŸ” PR mergeable state:", prDetails.mergeable_state);
202 return new Response("Notification sent to Slack", { status: 200 });
203 } catch (prError) {
204 console.error("❌ Error fetching PR details or sending notification:", prError);
205 console.error("❌ Error stack:", prError.stack);
206 return new Response(`Error: ${prError.message}\nStack: ${prError.stack}`, { status: 500 });
311}
312
313// Fetch detailed PR information including checks status
314async function fetchPRDetails(repo: string, prNumber: number) {
315 console.log(`πŸ” Starting fetchPRDetails for PR #${prNumber} in ${repo}`);
316
317 const token = Deno.env.get("GITHUB_TOKEN");
324 // Get PR details
325 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
326 console.log("πŸ” Fetching from GitHub API URL:", url);
327
328 let response;
329 try {
330 response = await fetch(url, {
331 headers: {
332 "Authorization": `token ${token}`,
339 console.log("πŸ” Response status text:", response.statusText);
340 console.log("πŸ” Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
341 } catch (fetchError) {
342 console.error("❌ Network error fetching PR details:", fetchError);
343 console.error("❌ Error stack:", fetchError.stack);
344 throw new Error(`Network error fetching PR details: ${fetchError.message}`);
345 }
346
364 }
365
366 throw new Error(`Failed to fetch PR details: ${response.status} ${response.statusText}`);
367 }
368
415 console.log("πŸ” Verifying PR is still mergeable before attempting merge");
416 try {
417 const prDetails = await fetchPRDetails(repo, prNumber);
418 console.log("πŸ” PR current mergeable status:", prDetails.mergeable);
419 console.log("πŸ” PR current mergeable state:", prDetails.mergeable_state);
458 let response;
459 try {
460 response = await fetch(url, {
461 method: "PUT",
462 headers: {
472 console.log("πŸ” Response status text:", response.statusText);
473 console.log("πŸ” Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
474 } catch (fetchError) {
475 console.error("❌ Network error during merge request:", fetchError);
476 console.error("❌ Error stack:", fetchError.stack);
477 return {
478 success: false,
479 message: `Network error during merge: ${fetchError.message}`,
480 };
481 }
631 let response;
632 try {
633 response = await fetch(slackWebhookUrl, {
634 method: "POST",
635 headers: {
642 console.log("πŸ” Response status text:", response.statusText);
643 console.log("πŸ” Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
644 } catch (fetchError) {
645 console.error("❌ Network error sending to Slack:", fetchError);
646 console.error("❌ Error stack:", fetchError.stack);
647 throw new Error(`Network error sending to Slack: ${fetchError.message}`);
648 }
649
110 console.log("πŸ” Current PR labels:", currentLabels);
111
112 // Fetch labels from all linked issues
113 const repo = payload.repository.full_name;
114 let allIssueLabels: string[] = [];
115
116 for (const issueNumber of issueNumbers) {
117 console.log(`πŸ” Fetching labels for issue #${issueNumber}`);
118 try {
119 const issue = await fetchIssue(repo, issueNumber);
120 const issueLabels = issue.labels.map(label => label.name);
121 console.log(`πŸ” Labels for issue #${issueNumber}:`, issueLabels);
128 }
129 } catch (error) {
130 console.error(`❌ Error fetching issue #${issueNumber}:`, error);
131 }
132 }
190}
191
192// Fetch issue details
193async function fetchIssue(repo: string, issueNumber: number): Promise<GitHubIssue> {
194 const token = Deno.env.get("GITHUB_TOKEN");
195
199
200 const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
201 console.log("πŸ” Fetching issue from:", url);
202
203 const response = await fetch(url, {
204 headers: {
205 "Authorization": `token ${token}`,
221 console.error("❌ GitHub API error text:", errorText);
222 }
223 throw new Error(`Failed to fetch issue: ${errorMessage}`);
224 }
225
240 console.log("πŸ” Sending labels update request to:", url);
241
242 const response = await fetch(url, {
243 method: "POST",
244 headers: {
166 console.log("πŸ” Sending title update request to:", url);
167
168 const response = await fetch(url, {
169 method: "PATCH",
170 headers: {

fetchPaginatedData2 file matches

@nbbaierβ€’Updated 1 week ago

FetchBasic1 file match

@fredmoonβ€’Updated 1 week ago