Update geocoding API calls to correctly parse JSON responses

Correctly parse the JSON response from the `/api/geocode` endpoint in the Sites page component by calling `.json()` on the response object.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/HdlP8Fl
This commit is contained in:
marco370 2025-10-23 14:03:38 +00:00
parent 17b1969255
commit e9f1c1e136

View File

@ -144,11 +144,12 @@ export default function Sites() {
setIsGeocoding(true); setIsGeocoding(true);
try { try {
const result: any = await apiRequest( const response = await apiRequest(
"POST", "POST",
"/api/geocode", "/api/geocode",
{ address } { address }
); );
const result = await response.json();
form.setValue("latitude", result.latitude); form.setValue("latitude", result.latitude);
form.setValue("longitude", result.longitude); form.setValue("longitude", result.longitude);
@ -181,11 +182,12 @@ export default function Sites() {
setIsGeocodingEdit(true); setIsGeocodingEdit(true);
try { try {
const result: any = await apiRequest( const response = await apiRequest(
"POST", "POST",
"/api/geocode", "/api/geocode",
{ address } { address }
); );
const result = await response.json();
editForm.setValue("latitude", result.latitude); editForm.setValue("latitude", result.latitude);
editForm.setValue("longitude", result.longitude); editForm.setValue("longitude", result.longitude);