From 62f8397c4a1947a27bf90b64fccf8fdcb16b4b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=B5=B7=E4=B8=80=E5=88=80?= <849005670@qq.com> Date: Wed, 17 Nov 2021 14:31:31 +0800 Subject: [PATCH] Update api.js --- src/assets/api.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index bb29d466..d44a4eb6 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -25,13 +25,19 @@ const req = (method, url, params, responseType) => { } } let http = fetch(url,obj).then(res => res.json()); - return http.then(response => response.data).catch(error => console.error('Error:', error)); + return http.then(response => response).catch(error => console.error('Error:', error)); } - - - - +export const handelResponse=(res, cb, errCb)=> { + console.log(res) + if (res.code == 200) { + cb(res) + } else { + if (typeof errCb == 'function') { + errCb() + } + } + } //营销计划列表 export const getPlanList = (params) => { return req('get', baseurl + "/plan", params)