62 try {
63 await sleepRand(15);
64 const response = await fetch(NOAA_URL_TKPK, {
65 headers: { "User-Agent": "https://www.val.town/v/kingishb/blackLobster" },
66 });
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }
29 app.all("*", async (c) => {
30 const { path } = c.req;
31 return await fetch(`https://api.val.town${path}`, {
32 method: c.req.method,
33 headers: c.req.raw.headers,
36 });
37
38 return app.fetch;
39}
86 const y = d3.select(this).attr("cy");
87
88 fetch(`/update?x=${x}&y=${y}&i=${d3.select(this).attr("idx")}`, { method: "post" });
89 d3.select(this).attr("stroke", null);
90 }
190 return new Response(body, { headers: { "Content-Type": "text/event-stream" } });
191});
192export default app.fetch;
17 console.log("🚨");
18
19 await fetch(DISCORD_WEBHOOK, {
20 method: "POST",
21 headers: {
108});
109
110export default app.fetch;
38});
39
40export default app.fetch;
33 });
34
35 return app.fetch(req);
36};
29 });
30
31 return app.fetch(req);
32};
1Create a simple hit counter that you can attach to any website via fetch .
2
3I created a web component to use this :
9 this.attachShadow({ mode: 'open' });
10 this.count = 0;
11 this.fetchCount();
12 }
13
14 fetchCount() {
15 fetch('https://triptych-hitcounter.web.val.run/')
16 .then(response => response.json())
17 .then(data => {
19 this.render();
20 })
21 .catch(error => console.error('Error fetching count:', error));
22 }
23