From 6dcb940bed984dcdc7ce22288e539782cf7fcb1c Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Wed, 17 Jul 2024 13:46:11 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20gracefully=20handle=20areas=20where=20el?= =?UTF-8?q?evation=20data=20doesn=E2=80=99t=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev-client/src/model/elevation/elevationService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev-client/src/model/elevation/elevationService.ts b/dev-client/src/model/elevation/elevationService.ts index 302f25ac6..255dfe2bd 100644 --- a/dev-client/src/model/elevation/elevationService.ts +++ b/dev-client/src/model/elevation/elevationService.ts @@ -35,7 +35,11 @@ export const getElevation = async ( const response = await fetch( `https://epqs.nationalmap.gov/v1/json/?${queryString}`, ); - const result = await response.json(); + const textResult = await response.text(); + if (textResult === 'Invalid or missing input parameters.') { + return; + } + const result = JSON.parse(textResult); elevation = parseFloat(result.value); } catch (error) {