jamiedubs-weatherlivestream.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { getWeather } from "https://esm.town/v/stevekrouse/getWeather";
export async function handler(request: Request) {
// pull location from query params
let url = new URL(request.url);
let location = url.searchParams.get("location") ?? "Brooklyn, NY";
let weather = await getWeather(location);
let feelsLike = weather.current_condition[0].FeelsLikeF;
let description = weather.current_condition[0].weatherDesc[0].value;
// await email({
// subject: `Weather now is ${description} and ${feelsLike}°F`,
// });
return Response.json({ ok: true, data: `${feelsLike}°F, ${description}` });
}
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!
v10
May 10, 2024