42
43 try {
44 const response = await fetch(`/generate-readme/${user}/${val}`);
45
46 if (!response.ok) {
29
302. **Generate:**
31 - Click on 'Generate README' and watch as the application swiftly fetches and processes the Val code to create a Markdown README.
32
333. **Copy and Share:**
42- **TailwindCSS:** For styling the application.
43- **Deno:** The server-side environment.
44- **ValTown SDK:** Integrated to fetch Val details.
45- **OpenAI GPT-4:** To generate natural language README content.
46- **JavaScript Modules (ESM):** For seamless module imports.
10 event.preventDefault();
11 const formData = new FormData(event.target);
12 const response = await fetch("/generate", {
13 method: "POST",
14 body: formData,
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
41 setStats(data);
42 }
43 fetchStats();
44 }, []);
45
128
129 useEffect(() => {
130 async function fetchUsageStats() {
131 const response = await fetch("/usage-stats");
132 const data = await response.json();
133 setUsageStats(data);
134 }
135 fetchUsageStats();
136 }, []);
137
141
142 try {
143 const response = await fetch("/", {
144 method: "POST",
145 body: JSON.stringify({
7const agent = new AtpAgent({
8 service: "https://public.api.bsky.app/",
9 // fetch, ideally we'd use our @std/fetch proxy here but that doesn't work and I don't know why
10});
11
14
15 useEffect(() => {
16 fetchMessages();
17 }, []);
18
19 const fetchMessages = async () => {
20 const response = await fetch("/messages");
21 const data = await response.json();
22 setMessages(data);
30 }
31 localStorage.setItem("chatUsername", username);
32 await fetch("/messages", {
33 method: "POST",
34 headers: { "Content-Type": "application/json" },
39 });
40 setNewMessage("");
41 fetchMessages();
42 };
43
91 const [autoScroll, setAutoScroll] = useState(true);
92
93 // Fetch saved sermons on component mount
94 useEffect(() => {
95 const fetchSermons = async () => {
96 try {
97 const response = await fetch(`${endpointURL}/sermons`);
98 const data = await response.json();
99 console.log("Fetched sermons:", data); // Debugging log
100 // Ensure data is an array, even if it's empty
101 setSermons(Array.isArray(data) ? data : []);
102 } catch (error) {
103 console.error("Failed to fetch sermons:", error);
104 // Set to empty array in case of error
105 setSermons([]);
107 };
108
109 fetchSermons();
110 }, []);
111
169
170 try {
171 const response = await fetch(`${endpointURL}/delete-sermon/${sermonId}`, {
172 method: "DELETE",
173 });
200
201 try {
202 const res = await fetch(`${endpointURL}/save-sermon`, {
203 method: "POST",
204 headers: {
233
234 try {
235 const res = await fetch(`${endpointURL}/stream`, {
236 method: "POST",
237 body: JSON.stringify({ question }),
16
17 useEffect(() => {
18 fetchData();
19 }, []);
20
21 const fetchData = async () => {
22 const response = await fetch("/api/data");
23 const data = await response.json();
24 setParticipants(data.participants);
28 const handleLogin = async (e) => {
29 e.preventDefault();
30 const response = await fetch("/api/login", {
31 method: "POST",
32 headers: { "Content-Type": "application/json" },
49 const handleSubmit = async (e) => {
50 e.preventDefault();
51 const response = await fetch("/api/update", {
52 method: "POST",
53 headers: { "Content-Type": "application/json" },
58 setPoints("");
59 setNote("");
60 fetchData();
61 }
62 };
64 const handleReset = async () => {
65 if (window.confirm("Are you sure you want to reset all points?")) {
66 const response = await fetch("/api/reset", { method: "POST" });
67 if (response.ok) {
68 fetchData();
69 }
70 }
72
73 const handleExportCSV = async () => {
74 const response = await fetch("/api/export-csv");
75 const blob = await response.blob();
76 const url = window.URL.createObjectURL(blob);
24 }
25 } catch (error) {
26 console.error("Error fetching sermons:", error);
27 return new Response(JSON.stringify([]), {
28 headers: { "Content-Type": "application/json" },
86 );
87 } catch (error) {
88 console.error("Error fetching sermons:", error);
89 return new Response(JSON.stringify([]), {
90 headers: { "Content-Type": "application/json" },
48app.get("/javascriptCourse", javascriptCourse);
49app.get("/javascriptCourse/fizzBuzzTest", fizzBuzzTest);
50export default app.fetch;