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=212&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 13481 results for "fetch"(6220ms)

Towniefetch.ts5 matches

@Syphrose1990•Updated 5 days ago
11 * Creates a tool for making HTTP requests to vals in a Val Town project
12 */
13export const makeFetchTool = (
14 { bearerToken, project, branch_id }: { bearerToken?: string; project?: any; branch_id?: string } = {},
15) =>
16 tool({
17 name: "fetch",
18 description: "Make an HTTP request to a Val Town val and return the response. Useful for testing HTTP vals.",
19 parameters: z.object({
68 return {
69 type: "error",
70 message: `Error fetching val at path '${valPath}': ${error.message}`,
71 };
72 }
83 return {
84 type: "error",
85 message: `The val at path '${valPath}' is not an HTTP val. Only HTTP vals can be called with fetch.`,
86 };
87 }
111 let response;
112 try {
113 response = await fetch(valEndpoint + urlPath, options);
114 } catch (error: any) {
115 // Return error information

Townie.cursorrules3 matches

@Syphrose1990•Updated 5 days ago
239
240 // Inject data to avoid extra round-trips
241 const initialData = await fetchInitialData();
242 const dataScript = `<script>
243 window.__INITIAL_DATA__ = ${JSON.stringify(initialData)};
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
290
291

TownieChatRouteSingleColumn.tsx6 matches

@Syphrose1990•Updated 5 days ago
49 files={project.data?.files}
50 branchId={branchId}
51 refetch={project.refetch}
52 />
53 </ProjectContext>
59 files,
60 branchId,
61 refetch,
62}: {
63 project: any;
64 files: any[];
65 branchId: string;
66 refetch: () => void;
67}) {
68 const [images, setImages] = useState<(string|null)[]>([]);
93 if (!messages?.length) return;
94 let last = messages.at(-1);
95 if (shouldRefetch(last)) {
96 refetch();
97 }
98 }, [messages]);
168}
169
170function shouldRefetch (message) {
171 for (let i = 0; i < message?.parts?.length; i++) {
172 let part = message.parts[i];

TownieBranchSelect.tsx1 match

@Syphrose1990•Updated 5 days ago
32 return;
33 }
34 branches.refetch();
35 if (res?.branch?.id) {
36 navigate(`/chat/${projectId}/branch/${res.branch.id}`);

untitled-4770Login.tsx1 match

@chinweike•Updated 5 days ago
19 try {
20 const endpoint = isRegistering ? '/api/auth/register' : '/api/auth/login';
21 const response = await fetch(endpoint, {
22 method: 'POST',
23 headers: {

untitled-4770App.tsx2 matches

@chinweike•Updated 5 days ago
23 const loadMessages = async () => {
24 try {
25 const response = await fetch('/api/messages');
26 const data = await response.json();
27 if (data.success) {
47 setLoading(true);
48 try {
49 const response = await fetch('/api/messages', {
50 method: 'POST',
51 headers: {

JobPostindex.ts1 match

@Vilho•Updated 5 days ago
34});
35
36export default app.fetch;

JobPostChatRoom.tsx6 matches

@Vilho•Updated 5 days ago
16 };
17
18 const fetchMessages = async () => {
19 try {
20 const response = await fetch('/api/chat/messages');
21 if (response.ok) {
22 const messagesData = await response.json();
25 }
26 } catch (error) {
27 console.error('Error fetching messages:', error);
28 } finally {
29 setLoading(false);
32
33 useEffect(() => {
34 fetchMessages();
35 // Poll for new messages every 3 seconds
36 const interval = setInterval(fetchMessages, 3000);
37 return () => clearInterval(interval);
38 }, []);
55 };
56
57 const response = await fetch('/api/chat/messages', {
58 method: 'POST',
59 headers: {

JobPostJobForm.tsx1 match

@Vilho•Updated 5 days ago
27
28 try {
29 const response = await fetch('/api/jobs', {
30 method: 'POST',
31 headers: {

JobPostJobBoard.tsx4 matches

@Vilho•Updated 5 days ago
9 const [showForm, setShowForm] = useState(false);
10
11 const fetchJobs = async () => {
12 try {
13 const response = await fetch('/api/jobs');
14 if (response.ok) {
15 const jobsData = await response.json();
17 }
18 } catch (error) {
19 console.error('Error fetching jobs:', error);
20 } finally {
21 setLoading(false);
24
25 useEffect(() => {
26 fetchJobs();
27 }, []);
28

GithubPRFetcher

@andybak•Updated 2 days ago

proxiedfetch1 file match

@jayden•Updated 3 days ago