Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export function weatherGovGrid({ lat, lon }): Promise<WeatherData> {
return fetchJSON(
`https://api.weather.gov/points/${lat},${lon}`,
);
}
interface Coordinate {
type: string;
coordinates: [
number,
number,
];
}
interface Distance {
unitCode: string;
value: number;
}
interface Bearing {
unitCode: string;
value: number;
}
interface RelativeLocation {
type: string;
geometry: Coordinate;
properties: {
city: string;
state: string;
distance: Distance;
bearing: Bearing;
};
}
interface Properties {
"@id": string;
"@type": string;
cwa: string;
forecastOffice: string;
gridId: string;
gridX: number;
gridY: number;
forecast: string;
forecastHourly: string;
forecastGridData: string;
observationStations: string;
relativeLocation: RelativeLocation;
forecastZone: string;
county: string;
fireWeatherZone: string;
timeZone: string;
radarStation: string;
}
interface WeatherData {
id: string;
type: string;
geometry: Coordinate;
properties: Properties;
}
October 23, 2023