From 85f19fa25a408c43a74d0e3e299c49d2af3f8c6a Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Wed, 23 Feb 2022 20:18:20 +0530 Subject: [PATCH] chore: Show error messages from server in agent APIs (#4055) --- .../routes/dashboard/settings/agents/AddAgent.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/agents/AddAgent.vue b/app/javascript/dashboard/routes/dashboard/settings/agents/AddAgent.vue index 5c854f248..f2940459e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/agents/AddAgent.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/agents/AddAgent.vue @@ -127,11 +127,16 @@ export default { this.showAlert(this.$t('AGENT_MGMT.ADD.API.SUCCESS_MESSAGE')); this.onClose(); } catch (error) { + const { + response: { data: { error: errorResponse = '' } = {} } = {}, + } = error; + let errorMessage = ''; if (error.response.status === 422) { - this.showAlert(this.$t('AGENT_MGMT.ADD.API.EXIST_MESSAGE')); + errorMessage = this.$t('AGENT_MGMT.ADD.API.EXIST_MESSAGE'); } else { - this.showAlert(this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE')); + errorMessage = this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE'); } + this.showAlert(errorResponse || errorMessage); } }, },