From 18e7736704bfe8b737d6f888f3eaca12fc4069cd Mon Sep 17 00:00:00 2001 From: Jerome Villiseck Date: Wed, 10 Jul 2024 11:18:56 +0200 Subject: [PATCH] - Optionnal chaining - Correction gestion des erreurs --- src/App.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 41b0c44..45b51ae 100644 --- a/src/App.vue +++ b/src/App.vue @@ -73,11 +73,10 @@ function addError(error) { } newError.description = 'Erreur ' + error.response.status } - if(error.response.data.detail){ - newError.description = error.response.data.detail - } - if(error.response.data.message){ - newError.description = error.response.data.message + if (error?.response?.data?.detail) { + newError.description = error.response.data.detail; + } else if (error?.response?.data?.message) { + newError.description = error.response.data.message; } if(error.request.url){ newError.description = 'Problème de disponibilité du fichier demandé'