From daf02c526155ba88943a54767937ce67b5eb3afc Mon Sep 17 00:00:00 2001 From: Cristian Merli Date: Tue, 17 May 2022 09:08:43 -0600 Subject: [PATCH] Fix reading status of undefined I believe this will fix the error: Cannot read properties of undefined (reading 'status') when there is no response (server down). --- lib/apisauce.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/apisauce.ts b/lib/apisauce.ts index 7862995..6ca9929 100644 --- a/lib/apisauce.ts +++ b/lib/apisauce.ts @@ -83,7 +83,7 @@ export const getProblemFromError = error => { if (axios.isCancel(error)) return CANCEL_ERROR // then check the specific error code - if (!error.code) return getProblemFromStatus(error.response.status) + if (!error.code) return getProblemFromStatus(error.response?.status) if (TIMEOUT_ERROR_CODES.includes(error.code)) return TIMEOUT_ERROR if (NODEJS_CONNECTION_ERROR_CODES.includes(error.code)) return CONNECTION_ERROR return UNKNOWN_ERROR