1
2
3
4
5
6
7
8
9
10
11
12
13
// This val fetches weather data from an open API
// The approach involves using the fetch API provided by Deno
// to retrieve weather information for a specific location
export default async function main(req: Request): Promise<Response> {
const apiUrl = "https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true";
const response = await fetch(apiUrl);
const weatherData = await response.json();
return new Response(JSON.stringify(weatherData), { headers: { "Content-Type": "application/json" } });
}