Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Fetch the sailing flag color from https://www.community-boating.org/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { fetch } from "https://esm.town/v/std/fetch";
export async function communityBoatingFlag() {
const response = await fetch("https://api.community-boating.org/api/flag");
const text = await response.text();
// Regex by Chat GPT :shrug:
const regex = /FLAG_COLOR\s*=\s*["']([^"']+)["']/;
const match = text.match(regex);
if (match && match[1]) {
return {
flagColor: match[1],
};
}
else {
throw new Error("Flag color not found");
}
}
October 23, 2023