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
// 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" },
});
}
janpaul123-valle_tmp_328293536271528244631103783931838.web.val.run
July 17, 2024