Public
HTTP (deprecated)
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
import { Hono } from "npm:hono@3";
const app = new Hono();
const WEATHER_API_KEY = Deno.env.get('WEATHER_API_KEY'); // Replace with your actual weather API key
const BASE_URL = "https://api.openweathermap.org/data/2.5/weather";
app.get("/", async (c) => {
const response = await fetch(
`${BASE_URL}?q=Brooklyn&units=metric&appid=${WEATHER_API_KEY}`
);
const weatherData = await response.json();
return c.json({
location: weatherData.name,
temperature: weatherData.main.temp,
description: weatherData.weather[0].description,
});
});
export default app.fetch;
stevekrouse-valwriter_output.web.val.run
July 15, 2024