error handling on wrong input in search bar
All checks were successful
Docker Build & Publish / Build Docker (push) Successful in 1m9s
All checks were successful
Docker Build & Publish / Build Docker (push) Successful in 1m9s
This commit is contained in:
parent
fcbb0b369a
commit
584176baff
@ -10,6 +10,9 @@ export async function getLocation(searchLocation: string): Promise<coordType>{
|
||||
throw new Error(`There was an error fetching the data`);
|
||||
}
|
||||
const data: LocationType = await res.json();
|
||||
if (!data.results[0].formatted_address){
|
||||
throw new Error(`Unable to find the address`);
|
||||
}
|
||||
return {
|
||||
name: data.results[0].formatted_address,
|
||||
geo: data.results[0].geometry.location
|
||||
|
@ -5,7 +5,7 @@ import { LocationContext } from "@/context/LocationContext";
|
||||
|
||||
export default function LocationSearch() {
|
||||
const [searchLocation, setSearchLocation] = useState("");
|
||||
const { geoLocation, setGeoLocation } = useContext(LocationContext);
|
||||
const { setGeoLocation } = useContext(LocationContext);
|
||||
const [pending, setPending] = useState(false);
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
|
Loading…
Reference in New Issue
Block a user