From acfdb3ae6f1b2dc46e9dffe5cde52ef8e4b313a1 Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Tue, 24 Sep 2019 09:37:01 +0300 Subject: [PATCH] Report errors from requests with the error json property --- src/utils/request.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/request.js b/src/utils/request.js index 7e9acc1e..271fe591 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -11,8 +11,13 @@ service.interceptors.response.use( response => response, error => { console.log('Error ' + error) + console.log(error.response.data) + + // If there's an "error" property in the json, use it + const edata = error.response.data.error ? error.response.data.error : error.response.data + Message({ - message: `${error.message} - ${error.response.data}`, + message: `${error.message} - ${edata}`, type: 'error', duration: 5 * 1000 })