指定接口返回格式

Former-commit-id: cecb249658d88621883d41111e27cafa8fff1c16 [formerly cecb249658d88621883d41111e27cafa8fff1c16 [formerly cecb249658d88621883d41111e27cafa8fff1c16 [formerly cecb249658d88621883d41111e27cafa8fff1c16 [formerly 0313b6b30ba57c3d746d55bae04ce0155150d983 [formerly c444a9dc9809f2e3c4aaa2263543f39a1d889ad8]]]]]
Former-commit-id: 2c176d51cf5f5c5b733b82c59c914aa1be4c1ea6
Former-commit-id: 96c28290eee4242d69f78109a03f535929d09b18
Former-commit-id: 5eea3eceaac422cf969bb4faac466572d3d92b0a [formerly 5beed5d7fbf4023c37aec42826e39309c76b8663]
Former-commit-id: eae4a65099c92ab9894db31bfbc98030022db2d9
Former-commit-id: 7760cadd99b92c032504897d62bfba3d2c1f5632
Former-commit-id: 942e214e53bee6c3142c6dfa490c972a6abbed8d
Former-commit-id: 1cd6734220f665448f4fd295fe7ca28e9eed361c
Former-commit-id: a0386b7bf1cfdf9aca4cbfee42518a4b485f42ea
This commit is contained in:
liyang
2018-08-27 09:10:30 +08:00
parent 3fb34c3517
commit b6448966e6
5 changed files with 49 additions and 25 deletions

View File

@@ -31,7 +31,18 @@ service.interceptors.request.use(
// 响应拦截器
service.interceptors.response.use(
response => {
return response.data
// dataAxios 是 axios 返回数据中的 data
const dataAxios = response.data
// 这个状态码是和后端约定的
const { code } = dataAxios
// 根据 code 进行判断
if (code === undefined) {
// 如果没有 code 代表这不是后端返回的数据(例如请求 D2Admin 最新版本)
return dataAxios
} else {
// 有 code 代表这是一个后端接口
return dataAxios.data
}
},
error => {
util.log.danger('>>>>>> Error >>>>>>')