35}
36
37// ----- fetch or read from file
38
39async function fetchOutages() {
40 const res = await fetch(OUTAGES_URL);
41 const json = await res.json();
42 return json as OutagesJson;
101export async function getOutages() {
102 // const outagesJson = await readOutages();
103 const outagesJson = await fetchOutages();
104
105 // Create check
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
1// ... imports ...
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
16// --------------------------
17
18async function fetchNews(queries: any, hours: number, lang: string, region: string) {
19 let news;
20 let results = [];
103export default async function(interval: Interval) {
104 try {
105 const results = await fetchNews(queries, hours, lang, region);
106 console.log(`${
107 results.map(q => {
41 { query, hours, lang, region }: { query: string; hours: number; lang: string; region: string },
42) {
43 const response = await fetch(
44 getFeedUrl(query, hours, lang, region),
45 );
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 // Los Angeles coordinates with Fahrenheit units
14 const response = await fetch(
15 "https://api.open-meteo.com/v1/forecast?latitude=34.0522&longitude=-118.2437¤t=temperature_2m,relative_humidity_2m,wind_speed_10m,weather_code&temperature_unit=fahrenheit&wind_speed_unit=mph&timezone=America%2FLos_Angeles"
16 );
17
18 if (!response.ok) {
19 throw new Error('Weather data fetch failed');
20 }
21
29 }
30
31 fetchWeather();
32 }, []);
33
34
35
36export default app.fetch;
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);