Public
Script
Forked from stevekrouse/getWeather
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export async function getWeather(location: string): Promise<WeatherResponse> {
return fetchJSON(`https://wttr.in/${location}?format=j1`);
}
export interface WeatherResponse {
current_condition: CurrentCondition[];
nearest_area: NearestArea[];
request: Request[];
weather: Weather[];
}
export interface CurrentCondition {
FeelsLikeC: string;
FeelsLikeF: string;
cloudcover: string;
humidity: string;
localObsDateTime: string;
observation_time: string;
precipInches: string;
precipMM: string;
pressure: string;
pressureInches: string;
temp_C: string;
temp_F: string;
uvIndex: string;
visibility: string;
visibilityMiles: string;
weatherCode: string;
weatherDesc: WeatherDesc[];
weatherIconUrl: WeatherDesc[];
winddir16Point: string;
winddirDegree: string;
windspeedKmph: string;
windspeedMiles: string;
}
export interface WeatherDesc {
value: string;
}
export interface NearestArea {
areaName: WeatherDesc[];
country: WeatherDesc[];
latitude: string;
longitude: string;
population: string;
region: WeatherDesc[];
weatherUrl: WeatherDesc[];
}
export interface Request {
query: string;
type: string;
}
export interface Weather {
astronomy: Astronomy[];
avgtempC: string;
avgtempF: string;
date: Date;
hourly: Hourly[];
maxtempC: string;
maxtempF: string;
mintempC: string;
mintempF: string;
sunHour: string;
totalSnow_cm: string;
uvIndex: string;
}
export interface Astronomy {
moon_illumination: string;
moon_phase: string;
moonrise: string;
moonset: string;
sunrise: string;
sunset: string;
}
export interface Hourly {
DewPointC: string;
DewPointF: string;
FeelsLikeC: string;
FeelsLikeF: string;
HeatIndexC: string;
HeatIndexF: string;
WindChillC: string;
WindChillF: string;
WindGustKmph: string;
WindGustMiles: string;
chanceoffog: string;
chanceoffrost: string;
chanceofhightemp: string;
chanceofovercast: string;
chanceofrain: string;
chanceofremdry: string;
chanceofsnow: string;
chanceofsunshine: string;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
May 22, 2024