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:
parent
cee9345bf1
commit
930c98a607
2 changed files with 58 additions and 39 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue