1
2
3
4
5
6
7
8
9
10
11
// This val retrieves the weather in Brooklyn, NY using the MetaWeather API
export default async function main(req: Request): Promise<Response> {
const response = await fetch("https://www.metaweather.com/api/location/2459115/");
const weatherData = await response.json();
return new Response(JSON.stringify(weatherData), {
headers: { "Content-Type": "application/json" },
});
}