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=317&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 5857 results for "fetch"(558ms)

karate_classesmain.tsx18 matches

@stevekrouse•Updated 3 months ago
97
98 useEffect(() => {
99 fetch("/api/classes")
100 .then(res => res.json())
101 .then(data => {
102 console.log("Fetched classes:", data);
103 setClasses(data);
104 })
105 .catch(error => console.error("Error fetching classes:", error));
106 }, []);
107
132
133 useEffect(() => {
134 console.log("Fetching class details for ID:", id);
135 fetch(`/api/classes/${id}`)
136 .then(res => res.json())
137 .then(data => {
138 console.log("Fetched class details:", data);
139 setClassInfo(data);
140 })
141 .catch(error => console.error("Error fetching class details:", error));
142
143 if (email) {
144 console.log("Checking registration status for email:", email);
145 fetch(`/api/classes/${id}/registration?email=${email}`)
146 .then(res => res.json())
147 .then(data => {
148 console.log("Fetched registration status:", data);
149 setIsRegistered(data.registered);
150 })
151 .catch(error => console.error("Error fetching registration status:", error));
152 }
153 }, [id, email]);
156
157 const handleRegister = () => {
158 fetch(`/api/classes/${id}/register`, {
159 method: "POST",
160 headers: { "Content-Type": "application/json" },
174
175 const handleCancel = () => {
176 fetch(`/api/classes/${id}/cancel`, {
177 method: "POST",
178 headers: { "Content-Type": "application/json" },
193 const handleDelete = () => {
194 if (window.confirm("Are you sure you want to delete this class?")) {
195 fetch(`/api/classes/${id}`, { method: "DELETE" })
196 .then(() => navigate("/classes"))
197 .catch(error => console.error("Error deleting class:", error));
266 useEffect(() => {
267 if (id) {
268 fetch(`/api/classes/${id}`)
269 .then(res => res.json())
270 .then(data => {
275 });
276 })
277 .catch(error => console.error("Error fetching class data:", error));
278 }
279 }, [id]);
291 const url = id ? `/api/classes/${id}` : "/api/classes";
292
293 fetch(url, {
294 method,
295 headers: { "Content-Type": "application/json" },
415 const emailList = emails.split(/[\s,]+/).filter(email => email.trim() !== "");
416
417 fetch(`/api/classes/${id}/bulk-add`, {
418 method: "POST",
419 headers: { "Content-Type": "application/json" },
738
739 if (url.pathname.startsWith("/api")) {
740 return app.fetch(request);
741 }
742

Priyam28Gptmain.tsx1 match

@priyam•Updated 3 months ago
29
30 try {
31 const response = await fetch("/chat", {
32 method: "POST",
33 headers: { "Content-Type": "application/json" },

OpenTowniegenerateCode.ts1 match

@pomdtr•Updated 3 months ago
26
27export async function generateCodeAnthropic(messages: Message[]): Promise<ValResponse | null> {
28 const system = await (await fetch(`${import.meta.url.split("/").slice(0, -1).join("/")}/system_prompt.txt`)).text();
29
30 const openai = new OpenAI({

cerebras_codermain.tsx1 match

@Sushant_99•Updated 3 months ago
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({

spotifyAPImain.tsx2 matches

@neverstew•Updated 3 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let spotifyAPI = ({ token, endpoint, ...params }) =>
4 fetchJSON(
5 `https://api.spotify.com/v1/${endpoint}${
6 "method" in params && ["POST", "PUT", "DELETE"].includes(params["method"])

valtowntownmain.tsx1 match

@charmaine•Updated 3 months ago
172});
173
174export default app.fetch.bind(app);
175
176const css = `

getSpotifyAccessTokenmain.tsx1 match

@neverstew•Updated 3 months ago
52 try {
53 // Get access token
54 const response = await fetch("https://accounts.spotify.com/api/token", {
55 method: "POST",
56 headers: {

OpenTownieindex.tsx1 match

@pomdtr•Updated 3 months ago
26
27 try {
28 const response = await fetch("/", {
29 method: "POST",
30 headers: { "authorization": "Bearer " + bearerToken },

OpenTowniesystem_prompt.txt2 matches

@pomdtr•Updated 3 months ago
155 * The main App component is rendered on the client.
156 * No server-side-specific code should be included in the App.
157 * Use fetch to communicate with the backend server portion.
158 */
159function App() {
178 * Server-only code
179 * Any code that is meant to run on the server should be included in the server function.
180 * This can include endpoints that the client side component can send fetch requests to.
181 */
182export default async function server(request: Request): Promise<Response> {

trackESMContentmain.tsx3 matches

@maxm•Updated 3 months ago
10const TABLE_NAME = `${KEY}_versions_v1`;
11
12async function fetchContent(url: string) {
13 const response = await fetch(url);
14 return await response.text();
15}
30
31 for (const url of URLS) {
32 const content = await fetchContent(url);
33 const latestVersion = await sqlite.execute(
34 `SELECT blob_key FROM ${TABLE_NAME} WHERE url = ? ORDER BY timestamp DESC LIMIT 1`,

fetchPaginatedData2 file matches

@nbbaier•Updated 1 week ago

tweetFetcher2 file matches

@nbbaier•Updated 1 week ago