@@ -566,14 +566,15 @@ export default {
566
566
.then(function (response) {
567
567
t.$router.push('/dogs')
568
568
}).catch( function (res) {
569
- if (res.response && res.response.data && res.response.data.errors) {
570
- t.errors = res.response.data.errors
571
- } else {
572
- var err = (res && res.response && res.response.data && res.response
573
- .data.message ?
574
- res.response.data.message : res)
575
- t.$root.$emit('globalError', err)
576
- t.$router.push('/')
569
+ if(res.response && res.response.data && res.response.data.errors && (res.response.data.errors[0].message === "Validation error")){
570
+ t.errors = res.response.data.errors[0];
571
+ }else{
572
+ let msg = res;
573
+ if(res && res.response && res.response.data && res.response.data.message){
574
+ msg = res.response.data.message
575
+ }
576
+ t.$root.$emit('globalError', msg)
577
+ t.$router.push('/home')
577
578
}
578
579
})
579
580
},
@@ -1892,21 +1893,23 @@ export default {
1892
1893
this.getAssociationsIds();
1893
1894
Queries.Book.update({url:url, variables:t.book})
1894
1895
.then(function (response) {
1895
- t.$router.push('/books')
1896
+ t.$router.push('/books')
1896
1897
}).catch( function (res) {
1897
- if (res.response && res.response.data && res.response.data.errors) {
1898
- t.errors = res.response.data.errors
1899
- } else {
1900
- var err = (res && res.response && res.response.data && res.response
1901
- .data.message ?
1902
- res.response.data.message : res)
1903
- t.$root.$emit('globalError', err)
1904
- t.$router.push('/')
1898
+ if(res.response && res.response.data && res.response.data.errors && (res.response.data.errors[0].message === "Validation error")){
1899
+ t.errors = res.response.data.errors[0];
1900
+ }else{
1901
+ let msg = res;
1902
+ if(res && res.response && res.response.data && res.response.data.message){
1903
+ msg = res.response.data.message
1904
+ }
1905
+ t.$root.$emit('globalError', msg)
1906
+ t.$router.push('/home')
1905
1907
}
1906
1908
})
1907
1909
},
1910
+
1908
1911
getOnlyIds(array){
1909
- return array.map((item)=>{ return item.id; });
1912
+ return array.map((item)=>{ return item.id; });
1910
1913
},
1911
1914
1912
1915
getAssociationsIds(){
@@ -2063,14 +2066,15 @@ export default {
2063
2066
.then(function (response) {
2064
2067
t.$router.push('/people')
2065
2068
}).catch( function (res) {
2066
- if (res.response && res.response.data && res.response.data.errors) {
2067
- t.errors = res.response.data.errors
2068
- } else {
2069
- var err = (res && res.response && res.response.data && res.response
2070
- .data.message ?
2071
- res.response.data.message : res)
2072
- t.$root.$emit('globalError', err)
2073
- t.$router.push('/')
2069
+ if(res.response && res.response.data && res.response.data.errors && (res.response.data.errors[0].message === "Validation error")){
2070
+ t.errors = res.response.data.errors[0];
2071
+ }else{
2072
+ let msg = res;
2073
+ if(res && res.response && res.response.data && res.response.data.message){
2074
+ msg = res.response.data.message
2075
+ }
2076
+ t.$root.$emit('globalError', msg)
2077
+ t.$router.push('/home')
2074
2078
}
2075
2079
})
2076
2080
},
0 commit comments