请求结果处理

merge-requests/3/merge
ch 3 years ago
parent 2d51a034be
commit 69aecdd145

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-03 23:04:45 * @Date: 2022-05-03 23:04:45
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-04 18:32:54 * @LastEditTime: 2022-05-09 09:40:57
* @Description: file content * @Description: file content
*/ */
let axios = null let axios = null
@ -16,15 +16,20 @@ export default function({app, $axios, req}) {
// } // }
// export default function ({app, $axios}) { // export default function ({app, $axios}) {
$axios.onRequest(()=>{ // $axios.onRequest(()=>{
// })
$axiosTk.onResponse(response => {
const result = response.data;
if(response.status === 200){
if(result.code === 'SUCCESS'){
return result.data;
}
return Promise.reject(result);
}
return Promise.reject({message:'请求出错'});
})
$axios.onResponse(res => {
if (res.status === 200) {
return res.data;
} else {
return Promise.reject(res.data.error);
}
}); });
axios = $axios; axios = $axios;
} }

Loading…
Cancel
Save