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=126&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 8624 results for "fetch"(1124ms)

HtmlSpecialCharsDemoindex.ts1 match

@wolf•Updated 2 weeks ago
15app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
16
17export default app.fetch;

HtmlSpecialCharsDemoApp.tsx1 match

@wolf•Updated 2 weeks ago
6
7 useEffect(() => {
8 fetch("https://htmlspecialcharsdemo.val.run/api/data")
9 .then(resp => resp.text())
10 .then(text => setData(text));

sdredirectedhtttpppromptBlackPlanarian1 match

@charmaine•Updated 2 weeks ago
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 return fetch(new URL(url.pathname + url.search, "https://charmaine--6a875a3820ff11f0b157569c3dd06744.web.val.run"), {
4 method: req.method,
5 headers: req.headers,

val_to_project_converterredirectService.ts12 matches

@charmaine•Updated 2 weeks ago
28 const projectUrl = `https://www.val.town/x/${username}/${projectName}`;
29
30 // First, get the project ID by fetching the project details
31 let projectId;
32 let endpointUrl: string | undefined; // Initialize as undefined, explicitly type
33 try {
34 const projectResponse = await fetch(`https://api.val.town/v1/alias/projects/${username}/${projectName}`, {
35 headers: {
36 "Authorization": `Bearer ${apiKey}`,
49 }
50
51 // Fetch the project files to get the endpoint URL
52 const filesResponse = await fetch(`https://api.val.town/v1/projects/${projectId}/files?path=`, {
53 headers: {
54 "Authorization": `Bearer ${apiKey}`,
57
58 if (!filesResponse.ok) {
59 // Still throw if fetching files fails
60 throw new Error(`Failed to get project files: ${filesResponse.status}`);
61 }
73 }
74 } catch (error) {
75 // Catch errors from fetching project details or files (but not the missing endpoint specifically)
76 console.error("Error getting project details or files:", error);
77 // Rethrow because fetching project details is critical for proceeding
78 throw new Error(`Error preparing project details: ${error.message}`);
79 }
97 try {
98 // First, get the val ID
99 const valResponse = await fetch(`https://api.val.town/v1/alias/${valOwner}/${valName}`, {
100 headers: {
101 "Authorization": `Bearer ${apiKey}`,
104
105 if (!valResponse.ok) {
106 throw new Error(`Failed to fetch val details: ${valResponse.status}`);
107 }
108
122 const redirectCode = `export default async function(req: Request): Promise<Response> {
123 const url = new URL(req.url);
124 return fetch(new URL(url.pathname + url.search, "${endpointUrl}"), {
125 method: req.method,
126 headers: req.headers,
148 console.log(`Version update body for ${valOwner}/${valName}:`, JSON.stringify(versionUpdateBody).substring(0, 200) + "...");
149
150 const versionUpdateResponse = await fetch(versionUpdateUrl, {
151 method: "POST",
152 headers: {
174 };
175
176 const readmeUpdateResponse = await fetch(readmeUpdateUrl, {
177 method: "PUT", // Use PUT as documented for updating val properties
178 headers: {

val_to_project_converterprojectService.ts12 matches

@charmaine•Updated 2 weeks ago
3// Define an intermediate type for the processing array
4interface ProcessingValInfo extends ValInfo {
5 val?: any; // Store the fetched val data here
6 success: boolean;
7 error?: string;
34 // Use existing project
35 projectId = existingProjectId;
36 // Fetch existing project details to get name and author
37 const projectDetailsResponse = await fetch(`https://api.val.town/v1/projects/${projectId}`, {
38 headers: { "Authorization": `Bearer ${apiKey}` },
39 });
40 if (!projectDetailsResponse.ok) {
41 const errorText = await projectDetailsResponse.text();
42 throw new Error(`Failed to fetch existing project details: ${errorText}`);
43 }
44 const projectDetails = await projectDetailsResponse.json();
67
68 // Create the new project
69 const projectResponse = await fetch("https://api.val.town/v1/projects", {
70 method: "POST",
71 headers: {
100 const convertedVals: ProcessingValInfo[] = []; // Use the defined type here
101
102 // First pass: fetch all vals and track them
103 for (const valInfo of vals) {
104 try {
105 // Fetch the val details
106 const valResponse = await fetch(`https://api.val.town/v1/alias/${valInfo.username}/${valInfo.valName}`, {
107 headers: { "Authorization": `Bearer ${apiKey}` },
108 });
115 valName: valInfo.valName,
116 success: false,
117 error: `Failed to fetch val: ${errorText}`,
118 });
119 continue;
131 username: valInfo.username,
132 valName: valInfo.valName,
133 val: val, // Store the fetched val
134 success: true,
135 });
155
156 // Add the file to the project (use the determined projectId)
157 const fileResponse = await fetch(`https://api.val.town/v1/projects/${projectId}/files?path=${filePath}`, {
158 method: "POST",
159 headers: {
188 // Generate and add README.md
189 const readmeContent = generateReadme(finalProjectName, vals, convertedVals);
190 await fetch(`https://api.val.town/v1/projects/${projectId}/files/README.md`, {
191 method: "POST",
192 headers: {

hiiiiii213123123123simpleAnalytics1 match

@charmaine•Updated 2 weeks ago
32 let func = `(async () => {
33 try {
34 await fetch(import.meta.url, {
35 method: "POST",
36 headers: {

cerebras_coderindex.ts1 match

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

cerebras_coderindex.ts1 match

@grosm4n•Updated 2 weeks ago
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
28
29 // create http request
30 const res = await fetch("https://api.capacities.io/save-to-daily-note", {
31 method: "POST",
32 headers: {
28
29 // create http request
30 const res = await fetch("https://api.capacities.io/save-to-daily-note", {
31 method: "POST",
32 headers: {

fetchPaginatedData2 file matches

@nbbaier•Updated 3 weeks ago

FetchBasic1 file match

@fredmoon•Updated 3 weeks ago