Improve location accuracy for weather data fetching

Add logging to show parsed location details and handle cases where resolved address is missing in the weather API response.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d43bd811-9372-45a7-8ac9-4a954c0538e1
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/d43bd811-9372-45a7-8ac9-4a954c0538e1/zoZabWF
This commit is contained in:
michaelschal committed 2025-08-15 11:31:25 +00:00
1 parent c65860cb85
commit 5045c98692
1 file changed
+5
+5
View File
@@ -260,6 +260,8 @@ export class WeatherService {
const data = await response.json();
console.log('🌍 API Response:', JSON.stringify(data, null, 2));
// L'API Visual Crossing retourne les informations de localisation
if (data.resolvedAddress) {
const address = data.resolvedAddress;
@@ -269,6 +271,8 @@ export class WeatherService {
const city = parts[0] || 'Ville inconnue';
const country = parts[parts.length - 1] || 'Pays inconnu';
console.log('🌍 Parsed location:', { city, country, fullLocation: address });
return {
city,
country,
@@ -276,6 +280,7 @@ export class WeatherService {
};
}
console.log('🌍 No resolvedAddress found in API response');
return null;
} catch (error) {
console.error("Erreur lors de la géolocalisation:", error);