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
import { fetch } from "https://esm.town/v/std/fetch";
export const simpleClimbing = (async () => {
const areas = [
{
name: "Holcomb",
id: 679,
mtnProjId: 105805238,
},
{
name: "Red Rock",
id: 560,
mtnProjId: 105731932,
},
{
name: "Joshua Tree",
id: 506,
mtnProjId: 105720495,
},
{
name: "Tahquitz",
id: 517,
mtnProjId: 105788020,
},
{
name: "Yosemite",
id: 518,
mtnProjId: 105833381,
},
{
name: "Woodson",
id: 718,
mtnProjId: 105791148,
},
{
name: "Culp",
id: 947,
mtnProjId: 106116317,
},
{
name: "Eagle Peak",
id: 1054,
mtnProjId: 107008184,
},
{
name: "El Cajon",
id: 750,
mtnProjId: 105793290,
},
{
name: "New Jack",
id: 677,
mtnProjId: 105865045,
},
{
name: "Mission Gorge",
id: 738,
mtnProjId: 105790250,
},
];
// const rawWeatherData = await fetch(
// `https://api.climbingweather.com/area/detail/738?days=1`,
// ).then((r) => r.json());
const rawWeatherData = await Promise.all(
areas.map(async (
a,
) => (await fetch(
`https://api.climbingweather.com/area/detail/${a.id}?days=1`,
).then((r) => r.json()).then((d) => ({
...d,
...a,
})))),
);
return rawWeatherData.map((w) => ({
id: w.areaId,
name: w.name,
hi: w.forecast.daily.data[0].temperatureHigh,
lo: w.forecast.daily.data[0].temperatureLow,
precipProb: parseFloat(w.forecast.daily.data[0].precipProbability),
windSpeed: w.forecast.daily.data[0].windSpeed,
windGust: w.forecast.daily.data[0].windGust,
mtnProjURL: `https://www.mountainproject.com/area/${w.mtnProjId}`,
color: w.color,
// hi: w.forecast.daily.data[0].temperatureHigh,
// lo: w.forecast.daily.data[0].temperatureLow,
}));
})();
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.