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