From f61060a5b765cdf579522ce1ea8193d37dc35ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Gro=C3=9F?= Date: Wed, 24 May 2023 17:09:19 +0200 Subject: [PATCH] Conditional chaining in case response is undefined --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 5aae7e4..7dd16db 100644 --- a/src/index.js +++ b/src/index.js @@ -42,7 +42,7 @@ async function pingEndpoint() { // Send an error message to the Discord webhook consecutiveFailures += 1; console.log(`ERROR PINGING API. HARD FAIL (${consecutiveFailures})`); - handleFailure(`Error occurred while pinging the API endpoint.\n${error.message}\n${STATUS_CODES[error.response.status]}`); + handleFailure(`Error occurred while pinging the API endpoint.\n${error.message}\n${STATUS_CODES[error.response?.status]}`); } }