perf:增加rawResponse属性,返回原始的数据
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tiesheng/npm-tool",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "npm tool package",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -92,16 +92,20 @@ async function req(url, options) {
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
let data = res.data;
|
||||
if (res.encrypt) {
|
||||
data = crypto.decrypt(data);
|
||||
data = Common.parseJSON(data, data);
|
||||
}
|
||||
resolve({data, recordsTotal: res.recordsTotal})
|
||||
if (options.rawResponse) {
|
||||
resolve(res);
|
||||
} else {
|
||||
GlobalConfig.getConfig().onHttpError(res);
|
||||
reject(res)
|
||||
if (res.code === 200) {
|
||||
let data = res.data;
|
||||
if (res.encrypt) {
|
||||
data = crypto.decrypt(data);
|
||||
data = Common.parseJSON(data, data);
|
||||
}
|
||||
resolve({data, recordsTotal: res.recordsTotal})
|
||||
} else {
|
||||
GlobalConfig.getConfig().onHttpError(res);
|
||||
reject(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user