forky_1742579787862index.ts2 matches
232});
233234// HTTP vals expect an exported "fetch handler"
235// This is how you "run the server" in Val Town with Hono
236export default app.fetch;
232});
233234// HTTP vals expect an exported "fetch handler"
235// This is how you "run the server" in Val Town with Hono
236export default app.fetch;
tangledNetmain.tsx11 matches
246}, [isDarkMode]);
247248const fetchFollowGraph = async () => {
249if (!startHandle.trim()) return;
250255256try {
257const response = await fetch("/fetch-graph", {
258method: "POST",
259body: JSON.stringify({ handle: startHandle }),
264setProgress(`Found ${sortedEdges.length} connections.`);
265} catch (error) {
266setProgress("Error fetching graph");
267console.error(error);
268} finally {
321onKeyDown={(e) => {
322if (e.key === "Enter" && !isLoading && startHandle.trim()) {
323fetchFollowGraph();
324}
325}}
332/>
333<button
334onClick={fetchFollowGraph}
335disabled={isLoading || !startHandle.trim()}
336style={{
461462export default async function server(request: Request): Promise<Response> {
463if (request.method === "POST" && new URL(request.url).pathname === "/fetch-graph") {
464const { handle } = await request.json();
465478async function didToHandle(did: string) {
479try {
480const plcResponse = await fetch(`https://plc.directory/${encodeURIComponent(did)}`);
481const plcData = await plcResponse.json();
482return plcData.alsoKnownAs[0]?.replace("at://", "") || did;
487}
488489async function fetchFollowGraph(startDid: string, maxDepth = 4) {
490const visited = new Set<string>();
491const uniqueEdges = new Set<string>();
499500try {
501const plcResponse = await fetch(`https://plc.directory/${encodeURIComponent(did)}`);
502const plcData = await plcResponse.json();
503const serviceEndpoint = plcData.service.find(
507if (!serviceEndpoint) return;
508509const followsResponse = await fetch(
510`${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${
511encodeURIComponent(
553}
554555const graph = await fetchFollowGraph(startDid);
556return new Response(JSON.stringify(graph), {
557headers: { "Content-Type": "application/json" },
6263<script>
64// Function to handle the PUT request using Fetch API
65async function updateName() {
66const oldName = document.getElementById('oldNameInput').value;
77
78try {
79const response = await fetch(window.location.href, {
80method: 'PUT',
81body: formData
BlackJackfrontend.html3 matches
62}
63
64// Fetch the greeting from the API
65const response = await fetch(url);
66
67if (!response.ok) {
76document.getElementById('result').classList.remove('hidden');
77} catch (error) {
78console.error('Error fetching greeting:', error);
79alert('Failed to get greeting. Please try again.');
80}
37const [result, setResult] = useState<string>("");
3839// Fetch the current game state
40const fetchGameState = async () => {
41try {
42const res = await fetch("/api/state");
43const data = await res.json();
44
78setLoading(true);
79try {
80const res = await fetch("/api/start", { method: "POST" });
81const data = await res.json();
82setGameState(data);
97setLoading(true);
98try {
99const res = await fetch("/api/hit", { method: "POST" });
100const data = await res.json();
101setGameState(data);
118setLoading(true);
119try {
120const res = await fetch("/api/stand", { method: "POST" });
121const data = await res.json();
122setGameState(data);
145setLoading(true);
146try {
147const res = await fetch("/api/booze", { method: "POST" });
148const data = await res.json();
149setGameState(data);
163// Initial load
164useEffect(() => {
165fetchGameState();
166}, []);
167
reactHonoStarterindex.ts2 matches
21});
2223// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;
cerebras_coderindex1 match
5async function servePublicFile(path: string): Promise<Response> {
6const url = new URL("./public/" + path, import.meta.url);
7const text = await (await fetch(url, {
8headers: {
9"User-Agent": "", // to transpile TS to JS