@alicloud/pop-core
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -72,3 +72,3 @@ 'use strict'; | ||
class Core { | ||
constructor(config) { | ||
constructor(config, verbose) { | ||
assert(config, 'must pass "config"'); | ||
@@ -88,2 +88,3 @@ assert(config.endpoint, 'must pass "config.endpoint"'); | ||
this.secretAccessKey = config.secretAccessKey; | ||
this.verbose = verbose === true; | ||
} | ||
@@ -111,18 +112,31 @@ | ||
const url = `${this.endpoint}/?${canonicalize(normalized)}`; | ||
// 4. send request | ||
var entry = { | ||
url: url, | ||
request: null, | ||
response: null | ||
}; | ||
// 4. send request | ||
return httpx.request(url).then((response) => { | ||
entry.request = response.req; | ||
entry.response = response; | ||
return httpx.read(response); | ||
}).then((buffer) => { | ||
var json = JSON.parse(buffer); | ||
if (json.Code) { | ||
var err = new Error(json.Message); | ||
err.data = json | ||
err.name = json.Code + 'Error'; | ||
err.data = json; | ||
err.code = json.Code; | ||
err.requestid = json.RequestId; | ||
err.url = url; | ||
err.name = json.Code + 'Error'; | ||
err.entry = entry; | ||
return Promise.reject(err); | ||
} | ||
if (this.verbose) { | ||
return [json, entry]; | ||
} | ||
return json; | ||
@@ -129,0 +143,0 @@ }); |
{ | ||
"name": "@alicloud/pop-core", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "AliCloud POP SDK core", | ||
@@ -10,3 +10,3 @@ "main": "lib/core.js", | ||
"lint": "eslint --fix lib", | ||
"test-cov": "istanbul cover --report html ./node_modules/.bin/_mocha -- --reporter spec --require co-mocha test/*.test.js" | ||
"test-cov": "istanbul cover --report html ./node_modules/.bin/_mocha -- --require co-mocha --reporter spec test/*.test.js" | ||
}, | ||
@@ -13,0 +13,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6737
167