196 }
197
198 const response = await fetch(
199 `${config.apiBase}/v2/vals/${valId}/files/content${queryParams}`,
200 {
42 // For blobs, we need to handle binary data differently
43 const url = `${config.apiBase}/v1/blob/${encodeURIComponent(key)}`
44 const response = await fetch(url, {
45 headers: {
46 "Authorization": `Bearer ${config.apiToken}`,
110
111 const url = `${config.apiBase}/v1/blob/${encodeURIComponent(key)}`
112 const response = await fetch(url, {
113 method: "POST",
114 headers: {
42});
43
44export default app.fetch;
45
9
10 useEffect(() => {
11 fetch("/api/styles")
12 .then(res => res.json())
13 .then(data => {
25});
26
27// HTTP vals expect an exported "fetch handler"
28// This is how you "run the server" in Val Town with Hono
29export default app.fetch;
9
10 useEffect(() => {
11 fetch("/api/colours")
12 .then(res => res.json())
13 .then(data => {
17 let aiResponse = "Sorry, something went wrong.";
18 try {
19 const openaiRes = await fetch("https://api.openai.com/v1/chat/completions", {
20 method: "POST",
21 headers: {
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
4app.get("/", (c) => c.text("Hello from Hono!"));
5app.get("/yeah", (c) => c.text("Routing!"));
6export default app.fetch;
7
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