Fix displaying error message when there is no error response
This commit is contained in:
parent
d47b3287bd
commit
408b9dcc64
1 changed files with 9 additions and 4 deletions
|
@ -10,14 +10,19 @@ const service = axios.create({
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => response,
|
response => response,
|
||||||
error => {
|
error => {
|
||||||
|
let errorMessage
|
||||||
console.log(`Error ${error}`)
|
console.log(`Error ${error}`)
|
||||||
console.log(error.response.data)
|
|
||||||
|
|
||||||
// If there's an "error" property in the json, use it
|
if (error.response) {
|
||||||
const edata = error.response.data.error ? error.response.data.error : 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
|
||||||
|
errorMessage = `${error.message} - ${edata}`
|
||||||
|
} else {
|
||||||
|
errorMessage = error
|
||||||
|
}
|
||||||
|
|
||||||
Message({
|
Message({
|
||||||
message: `${error.message} - ${edata}`,
|
message: errorMessage,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
duration: 5 * 1000
|
duration: 5 * 1000
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue