195 try {
196 // First, get coordinates for the city
197 const geoResponse = await fetch(
198 `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(cityInput.value)}&count=1&language=en&format=json`
199 );
207
208 // Then, get weather data
209 const weatherResponse = await fetch(
210 `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true&temperature_unit=celsius`
211 );
225 weatherInfo.innerHTML = `
226 <p class="text-red-500">
227 ${error.message || 'Unable to fetch weather data'}
228 </p>
229 `;
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
180
181 try {
182 const response = await fetch("/", {
183 method: "POST",
184 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
180
181 try {
182 const response = await fetch("/", {
183 method: "POST",
184 body: JSON.stringify({
190
191 try {
192 const response = await fetch("/", {
193 method: "POST",
194 body: JSON.stringify({
180
181 try {
182 const response = await fetch("/", {
183 method: "POST",
184 body: JSON.stringify({
181 try {
182 throw new Error("Generation Error: " + await response.text());
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
180
181 try {
182 const response = await fetch("/", {
183 method: "POST",
184 body: JSON.stringify({