Skip to content

Commit

Permalink
0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
HadiChan committed Jun 3, 2019
1 parent 81e46ce commit 902db77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ function ddvRestFulApi (path, requests, response) {
}.bind(this))
.then(function (body) {
if (this.isAuth === true) {
return ddvRestFulApiNextRun(this.auth, body, this.requests, this.response, this.request, this.onAccessKey, 0, (api.onAccessKeyTrySum || 3), isNative)
return ddvRestFulApiNextRun(this.auth, body, this.requests, this.response, this.request, this.onAccessKey, 0, (api.onAccessKeyTrySum || 3), isNative, api)
} else {
return this.request(auth.getUri(), body, auth.method, auth.headers, api)
.then(function (res) {
auth = body = void 0
return isNative === true ? res : parseDataByBody(res)
})
.then(function (res) {
auth = body = void 0
return isNative === true ? res : parseDataByBody(res)
})
}
}.bind(this))
.then(function (res) {
Expand Down Expand Up @@ -183,7 +183,7 @@ function ddvRestFulApi (path, requests, response) {
})
}
// 运行这个请求
function ddvRestFulApiNextRun (auth, body, requests, response, requestRun, onAccessKey, tryNum, trySum, isNative) {
function ddvRestFulApiNextRun (auth, body, requests, response, requestRun, onAccessKey, tryNum, trySum, isNative, api) {
// options.isServerNode = (requests && response && true) || false
// ====设定请求对象====
tryNum = tryNum || 0
Expand All @@ -196,7 +196,7 @@ function ddvRestFulApiNextRun (auth, body, requests, response, requestRun, onAcc
delete auth.headers['Authorization']
}
auth.headers['Authorization'] = auth.getAuthString()
return requestRun(auth.getUri(), body, auth.method, auth.headers)
return requestRun(auth.getUri(), body, auth.method, auth.headers, api)
.then(function (res) {
auth = body = void 0
return isNative === true ? res : parseDataByBody(res)
Expand All @@ -205,7 +205,7 @@ function ddvRestFulApiNextRun (auth, body, requests, response, requestRun, onAcc
var r
if (parseInt(e.statusCode) === 403 && tryNum < trySum) {
// 重新运行一次
r = ddvRestFulApiNextRun(auth, body, requests, response, requestRun, onAccessKey, (tryNum + 1), trySum, isNative)
r = ddvRestFulApiNextRun(auth, body, requests, response, requestRun, onAccessKey, (tryNum + 1), trySum, isNative, api)
} else {
// 还是原路抛出错误
r = isNative === true ? e : parseDataByBody(e, true)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ddv-restful-api",
"version": "0.4.4",
"version": "0.4.5",
"description": "ddv-restful-api",
"main": "./index.js",
"scripts": {
Expand Down

0 comments on commit 902db77

Please sign in to comment.