From 79855a9536725253c69a1fbd3ace8d516ae11104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Moreira?= Date: Mon, 17 Mar 2025 18:30:05 +0000 Subject: [PATCH] fix response possibily undefined TS error --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3023b30..cc160cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -141,7 +141,7 @@ export default async function (manager: Manager, settings: ComponentSettings) { const response = await manager.fetch( `https://wttr.in/${location}?format=j1` ) - const data = await response.json() + const data = response?.json() ?? null const [summary] = data.current_condition const { temp_C } = summary return `

Temperature in ${location} is: ${temp_C} ℃

` @@ -160,7 +160,7 @@ export default async function (manager: Manager, settings: ComponentSettings) { const response = await manager.fetch( `https://wttr.in/${location}?format=j1` ) - const data = await response.json() + const data = response?.json() ?? null const [summary] = data.current_condition const { temp_C } = summary return `

Temperature in ${location} is: ${temp_C} ℃

`