第一种是axios发出请求后在then()中的第二个参数中处理error.
apiPost(url, data) {
return new Promise((resolve, reject) => {
axios.post(url, data).then((response) => {
resolve(response.data)
}, (response) => {
handleError(response)
_g.closeGlobalLoading()
})
})
},
第二种是axios发出请求后通过catch()捕捉error后处理。
apiPost(url, data) {
return new Promise((resolve, reject) => {
axios.post(url, data).then((response) => {
resolve(response.data)
}).catch(function(error){
handleError(error)
_g.closeGlobalLoading()
})
})
},