1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 23:39:37 +02:00

fix(geocoding): improve error handling and response validation in search_google function

This commit is contained in:
Sean Morley 2025-06-16 11:47:36 -04:00
parent cee9345bf1
commit 930c98a607
2 changed files with 58 additions and 39 deletions

View file

@ -172,12 +172,18 @@
}
let res = await fetch(`/api/reverse-geocode/search/?query=${query}`);
console.log(res);
let data = (await res.json()) as GeocodeSearchResult[];
places = data;
if (data.length === 0) {
let data = (await res.json()) as GeocodeSearchResult[] | { error: string };
if ('error' in data) {
places = [];
noPlaces = true;
} else {
noPlaces = false;
places = data;
if (data.length === 0) {
noPlaces = true;
} else {
noPlaces = false;
}
}
}