How to use SECRETS in Functions?
Step 1
Step 2
async ({ city_name }) => {
const API_KEY = process.env.YOUR_API_KEY;
if (!API_KEY) throw new Error("API key not found in environment variables.");
const encodedCityName = encodeURIComponent(city_name);
const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${encodedCityName}&appid=${API_KEY}&units=metric`);
if (!response.ok) throw new Error(`Error ${response.status}: ${response.statusText}`);
return { weather_data: await response.json() };
};Step 3

Step 4
Step 5

Last updated
Was this helpful?
